-
Notifications
You must be signed in to change notification settings - Fork 382
Description
Feature description
AMP requires that any element with an on event handler attribute also have a tabindex and a role=button. Currently, however, you can create AMP content in WordPress and validation errors will leak.
Consider a Custom HTML block containing:
<span on="tap:AMP.print">Print!</span>Two validation errors leak to the frontend:
The reason for this the AMP plugin does not yet support the trigger like the on attribute spec has:
attrs: {
name: "on"
trigger: {
if_value_regex: "tap:.*"
also_requires_attr: "role"
also_requires_attr: "tabindex"
}
}
There are currently 22 instances of trigger in the protoascii, and each one is for also_requires_attr. This is currently called out as a todo:
amp-wp/includes/sanitizers/class-amp-tag-and-attribute-sanitizer.php
Lines 20 to 25 in 2549ca3
| * @todo Need to check the following items that are not yet checked by this sanitizer: | |
| * | |
| * - `also_requires_attr` - if one attribute is present, this requires another. | |
| * - `ChildTagSpec` - Places restrictions on the number and type of child tags. | |
| * - `if_value_regex` - if one attribute value matches, this places a restriction | |
| * on another attribute/value. |
The tag-and-attribute sanitizer needs to be updated to support this constraint. This will include updating the Python spec parser to extract these values. When a failure is encountered a new validation error code should be raised. (Currently it is UNKNOWN in the AMP validator but we can do something specific.)
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Implementation brief
QA testing instructions
Demo
Changelog entry
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
