* Removes duplicate attributes from the attribute list. This is consistent * with HTML5 parsing error handling rules, only the first attribute with * each attribute name is considered, the remainder are ignored.
()
| 309 | * each attribute name is considered, the remainder are ignored. |
| 310 | */ |
| 311 | dedupeAttrs() { |
| 312 | /** @type {!Array<!Object>} */ |
| 313 | const newAttrs = []; |
| 314 | /** @type {string} */ |
| 315 | let lastAttrName = ''; |
| 316 | for (const attr of this.attrs_) { |
| 317 | if (lastAttrName !== attr.name) { |
| 318 | newAttrs.push(attr); |
| 319 | } |
| 320 | lastAttrName = attr.name; |
| 321 | } |
| 322 | this.attrs_ = newAttrs; |
| 323 | } |
| 324 | /** |
| 325 | * Returns the value of a given attribute name. If it does not exist then |
| 326 | * returns null. |