Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix generation of validation error when element has multiple invalid attributes #1461


Copy link

@westonruter westonruter commented Sep 24, 2018

Consider HTML that has an element with multiple invalid attributes:

	class="wp-embedded-content amp-wp-enforced-sizes amp-wp-5e9b0a2"
	title="“Lorem Ipsum” — WordPress Develop's"

This is the HTML generated when adding a post embed. The underlying iframe element has three attributes that are invalid AMP:

  • security
  • marginwidth
  • marginheight

So three validation errors are generated. If you bulk accept the three validation errors, and the page is then re-validated, behold only one the first validation error shows as being accepted. Why? It's because in this case the security attribute is removed and so when the subsequent validation errors are generated, they no longer contain the security attribute among their element_attributes and so they are considered to be completely different validation errors. If you then bulk-accept all again, then only the validation error for the marginwidth validation error becomes accepted, whereas marginheight is not. So you then have to accept a third time. You can also see this reflected in the Error Index:


The fix is to simply make sure that we obtain all element_attributes for the validation error before we start iterating over the invalid attributes to remove them.

This is specifically an issue when auto-accepting of validation errors is not enabled, that is in paired mode.

@westonruter westonruter added this to the v1.0 milestone Sep 24, 2018
@westonruter westonruter requested a review from amedina Sep 24, 2018
Copy link

@amedina amedina left a comment

Ship it.

@westonruter westonruter merged commit dfdf338 into develop Sep 24, 2018
2 checks passed
@westonruter westonruter deleted the fix/validation-errors-for-elements-with-multiple-invalid-attributes branch Sep 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants