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.
16 lines
347 B
JavaScript
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;
|
|
}
|