mwoffliner
Version:
MediaWiki ZIM scraper
28 lines • 756 B
JavaScript
const DOMUtils = {
deleteNode(node) {
if (!node) {
return;
}
if (node.parentNode) {
node.parentNode.removeChild(node);
}
else {
node.outerHTML = '';
}
node = undefined;
},
appendToAttr(node, attr, val) {
const oldVal = node.getAttribute(attr);
const valToSet = oldVal ? `${oldVal} ${val}` : val;
node.setAttribute(attr, valToSet);
},
nextElementSibling(node) {
let sibling = node.nextSibling;
while (sibling && sibling.nodeType !== 1 /* ELEMENT_NODE */) {
sibling = sibling.nextSibling;
}
return sibling;
},
};
export default DOMUtils;
//# sourceMappingURL=DOMUtils.js.map