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

Merged
merged 1 commit into from Sep 24, 2018

Conversation

Projects
None yet
2 participants
@westonruter
Member

westonruter commented Sep 24, 2018

Consider HTML that has an element with multiple invalid attributes:

<amp-iframe
	class="wp-embedded-content amp-wp-enforced-sizes amp-wp-5e9b0a2"
	sandbox="allow-scripts"
	security="restricted"
	src="https://src.wordpress-develop.test/2018/09/24/lorem-ipsum-2/embed/#?secret=ELp4qNLN1k"
	data-secret="ELp4qNLN1k"
	width="600"
	height="338"
	title="“Lorem Ipsum” — WordPress Develop's"
	frameborder="0"
	marginwidth="0"
	marginheight="0"
	scrolling="no"
	layout="intrinsic"
>
</amp-iframe>

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:

image

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

@amedina

Ship it.

@westonruter westonruter merged commit dfdf338 into develop Sep 24, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@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