diff --git a/.eslintignore b/.eslintignore index 642271f..92872bb 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,3 @@ node_modules/ -coverage/ \ No newline at end of file +coverage/ +.nyc_output diff --git a/lib/dom-filter.js b/lib/dom-filter.js index 2d23cb3..85fd9a3 100644 --- a/lib/dom-filter.js +++ b/lib/dom-filter.js @@ -6,10 +6,10 @@ const CSSselect = require('css-select'); class Filter { constructor(hexo, excludes) { this.hexo = hexo; - this.selectors = excludes.map(this._compile); + this.selectors = excludes.map(this._compile.bind(this)); } - _compile = selector => { + _compile(selector) { try { return CSSselect.compile(selector); } catch (err) { @@ -18,18 +18,18 @@ class Filter { } } - match = node => { + match(node) { // not match any return !this.selectors.some(s => s(node)); } - filter = nodes => { + filter(nodes) { // remove inner nodes that doesn't match domutils.filter(n => !this.match(n), nodes) .forEach(node => domutils.removeElement(node)); // only keep top level nodes that match - return nodes.filter(this.match); + return nodes.filter(this.match.bind(this)); } }