| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 for (let element of this.getElements(prefix, subtree, styles)) | 320 for (let element of this.getElements(prefix, subtree, styles)) |
| 321 yield [makeSelector(element), subtree]; | 321 yield [makeSelector(element), subtree]; |
| 322 }, | 322 }, |
| 323 | 323 |
| 324 *getElements(prefix, subtree, styles) | 324 *getElements(prefix, subtree, styles) |
| 325 { | 325 { |
| 326 let actualPrefix = (!prefix || incompletePrefixRegexp.test(prefix)) ? | 326 let actualPrefix = (!prefix || incompletePrefixRegexp.test(prefix)) ? |
| 327 prefix + "*" : prefix; | 327 prefix + "*" : prefix; |
| 328 | 328 |
| 329 let elements = scopedQuerySelectorAll(subtree, actualPrefix); | 329 let elements = scopedQuerySelectorAll(subtree, actualPrefix); |
| 330 |
| 330 if (elements) | 331 if (elements) |
| 331 { | 332 { |
| 333 let lastRoot = null; |
| 332 for (let element of elements) | 334 for (let element of elements) |
| 333 { | 335 { |
| 336 // For a filter like div:-abp-contains(Hello) and a subtree like |
| 337 // <div id="a"><div id="b"><div id="c">Hello</div></div></div> |
| 338 // we're only interested in div#a |
| 339 if (lastRoot && lastRoot.contains(element)) |
| 340 { |
| 341 yield null; |
| 342 continue; |
| 343 } |
| 344 |
| 345 lastRoot = element; |
| 346 |
| 334 if (this._regexp && this._regexp.test(element.textContent)) | 347 if (this._regexp && this._regexp.test(element.textContent)) |
| 335 yield element; | 348 yield element; |
| 336 else | 349 else |
| 337 yield null; | 350 yield null; |
| 338 } | 351 } |
| 339 } | 352 } |
| 340 } | 353 } |
| 341 }; | 354 }; |
| 342 | 355 |
| 343 function PropsSelector(propertyExpression) | 356 function PropsSelector(propertyExpression) |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 characterData: shouldObserveCharacterData(this.patterns), | 835 characterData: shouldObserveCharacterData(this.patterns), |
| 823 subtree: true | 836 subtree: true |
| 824 } | 837 } |
| 825 ); | 838 ); |
| 826 this.document.addEventListener("load", this.onLoad.bind(this), true); | 839 this.document.addEventListener("load", this.onLoad.bind(this), true); |
| 827 } | 840 } |
| 828 } | 841 } |
| 829 }; | 842 }; |
| 830 | 843 |
| 831 exports.ElemHideEmulation = ElemHideEmulation; | 844 exports.ElemHideEmulation = ElemHideEmulation; |
| OLD | NEW |