Skip to content

Leaked validation errors for implicit layout "container" without width/height #4465

@westonruter

Description

@westonruter

Bug Description

Given this markup in a Custom HTML block:

<amp-ad type="adsense" data-ad-client="ca-pub-123" data-ad-slot="456" data-ad-format="auto" data-full-width-responsive="true"><span overflow=""></span></amp-ad>

This is leaking a validation error to the frontend:

Incomplete layout attributes specified for tag 'amp-ad'. For example, provide attributes 'width' and 'height'.

I thought that this would have been prevented by #3728.

This was discovered in a support topic.

Expected Behaviour

AMP components that have neither a layout nor width/height attributes should be removed entirely. An appropriate validation error should be raised in the plugin.

The corresponding AMP validation error constant is MISSING_LAYOUT_ATTRIBUTES.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

Implementation brief

QA testing instructions

  1. Create a new post.
  2. Add the following markup into a "Custom HTML" block on the page:
    <amp-img src="https://placeholder.com/350"></amp-img>
  3. Publish the page and visit its AMP version.
  4. Verify: The page should not show any validation errors (except for the "dev-mode" one) for the page.
  5. Go to the "Validate" screen for the page.
  6. Verify: The page should have 1 validation error with the following text:

    Incomplete layout attributes specified for tag amp-img. For example, provide attributes width and height.

Demo

Before

Image 2020-04-07 at 5 44 53 AM
The plugin's validation doesn't show any errors for the post.

Image 2020-04-07 at 5 45 30 AM
However, the AMP validator complains about the post.

After

Image 2020-04-07 at 5 45 52 AM
The plugin's validation catches the two offending elements and removes them.

Image 2020-04-07 at 5 46 04 AM
The validation issues are not leaked into the AMP validator anymore.

Changelog entry

Metadata

Metadata

Assignees

Labels

BugSomething isn't workingChangeloggedWhether the issue/PR has been added to release notes.ValidationWS:CoreWork stream for Plugin core

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions