While trying to validate a small Drupal site using the W3C validation tool (http://validator.w3.org/), I got some errors which were related to the addressfield module.
Attribute x-autocompletetype not allowed on element span at this point.
…anization" autocomplete="organization">Some Company Name</span></div><div clas…
Attribute autocomplete not allowed on element span at this point.
…anization" autocomplete="organization">Some Company Name</span></div><div clas…
Is there any use to those attributes on a non-input element? If not, I think it would be nice not to output them (cleaner, lighter and more valid code).
Comment | File | Size | Author |
---|---|---|---|
#1 | w3c_validation_errors-2262841-1.patch | 884 bytes | DomoSapiens |
Comments
Comment #1
DomoSapiens CreditAttribution: DomoSapiens commentedI changed the theme_addressfield_container function, to make sure only the class are printed in the elements.
Comment #2
bojanz CreditAttribution: bojanz commentedGood idea. Tweaked the patch & committed it. Thanks!
Comment #4
lmeurs CreditAttribution: lmeurs commentedUnfortunately this patch removes *all attributes* but the class name, including ie. the ID attribute which cripples Addressfield NL Postcode.
It also assumes the existence of the class name attribute which could result in warnings when none provided.
Comment #6
bojanz CreditAttribution: bojanz commentedReverted the patch.
We need to change it so that it only removes "autocomplete" and "x-autocompletetype" attributes.
Thanks for testing.
Comment #7
bojanz CreditAttribution: bojanz commentedPushed a different fix that only touches the problematic attributes.
Comment #9
AohRveTPV CreditAttribution: AohRveTPV commentedThese validation errors still seem to occur in 7.x-1.0-rc1 for select elements:
Attribute x-autocompletetype not allowed on element select at this point.
…d_foo[und][0][country]"><option value="AF">Afghanistan</option>…
Attribute autocomplete not allowed on element select at this point.
…d_foo[und][0][country]"><option value="AF">Afghanistan</option>…
Comment #10
bojanz CreditAttribution: bojanz commentedThe select must have those attributes, only the span validation errors were fixable. The rest is out of our hands.
Comment #11
AohRveTPV CreditAttribution: AohRveTPV commentedautocomplete does not look to be a valid attribute for the select element:
http://www.w3.org/html/wg/drafts/html/master/forms.html#the-select-element
It is valid for the input element:
http://www.w3.org/html/wg/drafts/html/master/forms.html#the-input-element
So it seems this could be fixed by only adding the autocomplete and x-autocompletetype attributes for form controls of type textfield.
plugins/format/address.inc
adds these attributes for form controls that are always or sometimes of type select. For instance, Country is always type select yet lines 120-121 add the autocomplete and x-autocompletetype attributes. Removing those lines removes the errors in I pasted in #9.Comment #12
bojanz CreditAttribution: bojanz commentedFrom your link:
Plenty of examples of selects with autocomplete tags under http://www.w3.org/html/wg/drafts/html/master/forms.html#autofill
Comment #13
AohRveTPV CreditAttribution: AohRveTPV commentedI missed that. Looks now like a W3C spec and validator bug. WHATWG has it corrected to list autocomplete as an attribute in their spec [0]. Will plan to file a bug with W3C.
[0] https://html.spec.whatwg.org/multipage/forms.html#the-select-element
Comment #15
CatsFromStonehenge CreditAttribution: CatsFromStonehenge commentedHi all
What happened with this issue in the end?
I've just checked Drupal 8.2 HTML via W3C and it gave the same error: