Closed milahu closed 3 years ago
closing, not worth the trouble. to get a unique list of parents:
const insrc = `<html>....</html>`;
const root = parse(insrc);
const childSelectors = ['.a', '.b'];
const parentNodes = [...new Set(root.querySelectorAll(childSelectors.join(',')).map(node => node.parentNode))];
console.dir(parentNodes.map(n => n.toString()));
so i can reduce a redundant list of nodes into a unique array
demo
```js // node-html-parser: `node._source.start` demo // get a unique and sorted list of parent nodes from multiple child nodes const { parse } = require('node-html-parser'); const insrc = `\a
b
a
b
a
b