MCPcopy Index your code
hub / github.com/ampproject/amphtml / hasDuplicateAttrs

Method hasDuplicateAttrs

validator/js/engine/htmlparser-interface.js:292–305  ·  view source on GitHub ↗

* Returns a duplicate attribute name if the tag contains two attributes * named the same, but with different attribute values. Same attribute name * AND value is OK. Returns null if there are no such duplicate attributes. * @return {?string}

()

Source from the content-addressed store, hash-verified

290 * @return {?string}
291 */
292 hasDuplicateAttrs() {
293 /** @type {string} */
294 let lastAttrName = '';
295 /** @type {string} */
296 let lastAttrValue = '';
297 for (const attr of this.attrs()) {
298 if (lastAttrName === attr.name && lastAttrValue !== attr.value) {
299 return attr.name;
300 }
301 lastAttrName = attr.name;
302 lastAttrValue = attr.value;
303 }
304 return null;
305 }
306 /**
307 * Removes duplicate attributes from the attribute list. This is consistent
308 * with HTML5 parsing error handling rules, only the first attribute with

Callers

nothing calls this directly

Calls 1

attrsMethod · 0.80

Tested by

no test coverage detected