Skip to content

Validation error for mandatory_anyof constraint when using data-amp-bind-src on amp-list #24661

@westonruter

Description

@westonruter

On blog.amp.dev we noticed a validation error starting to happen after ampproject/amp.dev#2934:

The tag 'amp-list' is missing a mandatory attribute - pick at least one of ['src','[src]'].

The markup being introduced included:

<amp-list data-amp-bind-src="query == undefined ? null : '/search/do?q=' + encodeURIComponent(query) + '&amp;locale=en'" binding="no" items="." height="10" layout="fixed-height" data-amp-bind-is-layout-container="query.length" load-more="auto" load-more-bookmark="nextUrl" reset-on-refresh="" single-item="">
	<template type="amp-mustache">...</template>
</amp-list>

As of ampproject/amp-wp#2974, the AMP WordPress plugin normalizes the bracketed amp-bind attribute syntax to data-amp-bind-*, so the original [src] is being converted here to data-amp-bind-src. The AMP validator then is flagging this as an error because of this mandatory_anyof constraint:

mandatory_anyof: "['src','[src]']"

A quick fix here would be to just add data-amp-bind-src to the list:

- mandatory_anyof: "['src','[src]']"
+ mandatory_anyof: "['src','[src]','data-amp-bind-src']"

However, this seems like a fix for a more fundamental issue where the validator needs to be more aware of the alternate syntax (#11115).

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions