Fix validation error reporting for invalid attributes on the HTML element #4190
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.
Summary
In #2500 the admin bar was suppressed from being shown when doing validation requests. Then in #3187 this was reverted because the addition of dev mode meant that the presence of the admin bar would no longer make pages invalid. Nevertheless, this had an unexpected consequence. When the
<html>
element has invalid attributes, these are never detected during validation because a validation request is made as an authenticated user, and thus the admin bar is present, and the admin bar entails dev mode being enabled. Since thedata-ampdevmode
attribute is on thehtml
element, any invalid attributes on the element are ignored for validation purposes. This is not expected.For example, activate Twenty Twenty and add this plugin code:
This adds two invalid AMP attributes, and when I look at an AMP page while logged-in, I see them:
Nevertheless, the admin bar shows ✅ for validity.
However, if I access the same AMP page while being logged-out, I see:
Similarly, if I go to validate the URL I see no validation errors:
This doesn't seem right.
To prevent this from happening, we can prevent showing the admin bar on the frontend as we were doing before. When that is done, the result when validating is:
This reverts commit 3380451 from #3187.
Todo
Checklist