You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
847 B
JavaScript
43 lines
847 B
JavaScript
/**
|
|
* @implements globalThis.NamedNodeMap
|
|
*/
|
|
export class NamedNodeMap extends Array {
|
|
constructor(ownerElement) {
|
|
super();
|
|
this.ownerElement = ownerElement;
|
|
}
|
|
|
|
getNamedItem(name) {
|
|
return this.ownerElement.getAttributeNode(name);
|
|
}
|
|
|
|
setNamedItem(attr) {
|
|
this.ownerElement.setAttributeNode(attr);
|
|
this.unshift(attr);
|
|
}
|
|
|
|
removeNamedItem(name) {
|
|
const item = this.getNamedItem(name);
|
|
this.ownerElement.removeAttribute(name);
|
|
this.splice(this.indexOf(item), 1);
|
|
}
|
|
|
|
item(index) {
|
|
return index < this.length ? this[index] : null;
|
|
}
|
|
|
|
/* c8 ignore start */
|
|
getNamedItemNS(_, name) {
|
|
return this.getNamedItem(name);
|
|
}
|
|
|
|
setNamedItemNS(_, attr) {
|
|
return this.setNamedItem(attr);
|
|
}
|
|
|
|
removeNamedItemNS(_, name) {
|
|
return this.removeNamedItem(name);
|
|
}
|
|
/* c8 ignore stop */
|
|
}
|