Fix generation of validation error when element has multiple invalid attributes #1461
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Consider HTML that has an element with multiple invalid attributes:
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 thesecurity
attribute among theirelement_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 themarginwidth
validation error becomes accepted, whereasmarginheight
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.