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).

CommentFileSizeAuthor
#1 w3c_validation_errors-2262841-1.patch884 bytesDomoSapiens
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DomoSapiens’s picture

I changed the theme_addressfield_container function, to make sure only the class are printed in the elements.

bojanz’s picture

Status: Active » Fixed

Good idea. Tweaked the patch & committed it. Thanks!

lmeurs’s picture

Unfortunately 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.

  • bojanz committed aa449bc on 7.x-1.x
    Revert "Issue #2262841 by DomoSapiens: W3C validation errors"
    
    This...
bojanz’s picture

Status: Fixed » Needs work

Reverted the patch.
We need to change it so that it only removes "autocomplete" and "x-autocompletetype" attributes.

Thanks for testing.

bojanz’s picture

Title: W3C validation errors » Fix W3C validation errors caused by the autocomplete attributes
Status: Needs work » Fixed

Pushed a different fix that only touches the problematic attributes.

  • bojanz committed 4c01689 on 7.x-1.x
    Issue #2262841 by DomoSapiens: W3C validation errors
    
AohRveTPV’s picture

Status: Fixed » Active

These 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>…

bojanz’s picture

Status: Active » Fixed

The select must have those attributes, only the span validation errors were fixable. The rest is out of our hands.

AohRveTPV’s picture

autocomplete 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.

bojanz’s picture

From your link:

Each input, select, and textarea element has an autofill hint set, an autofill scope, an autofill field name, and an IDL-exposed autofill value.

Plenty of examples of selects with autocomplete tags under http://www.w3.org/html/wg/drafts/html/master/forms.html#autofill

AohRveTPV’s picture

I 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

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

CatsFromStonehenge’s picture

Hi 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:

Error: Attribute autocorrect not allowed on element input at this point.
From line 213, column 9; to line 213, column 274
>↩        <input autocorrect="off" autocapitalize="off" spellcheck="false" autofocus="autofocus" data-drupal-s…"" size="60" maxlength="254" class="form-email required" required="required" aria-required="true" />↩↩