extra-dom
Version:
Utilities for DOM
14 lines (13 loc) • 326 B
text/typescript
export function removeAttributes(
node: Node
, predicate: (name: string) => unknown
): void {
if (node instanceof Element) {
const attributeNames = Array.from(node.attributes).map(x => x.name)
for (const name of attributeNames) {
if (predicate(name)) {
node.removeAttribute(name)
}
}
}
}