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.
mercury-parser/src/utils/dom/set-attrs.js

16 lines
347 B
JavaScript

export default function setAttrs(node, attrs) {
if (node.attribs) {
node.attribs = attrs;
} else if (node.attributes) {
while (node.attributes.length > 0) {
node.removeAttribute(node.attributes[0].name);
}
Reflect.ownKeys(attrs).forEach((key) => {
node.setAttribute(key, attrs[key]);
});
}
return node;
}