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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 for (let element of this.getElements(prefix, subtree, styles)) | 323 for (let element of this.getElements(prefix, subtree, styles)) |
324 yield [makeSelector(element, ""), subtree]; | 324 yield [makeSelector(element, ""), subtree]; |
325 }, | 325 }, |
326 | 326 |
327 *getElements(prefix, subtree, styles) | 327 *getElements(prefix, subtree, styles) |
328 { | 328 { |
329 let actualPrefix = (!prefix || incompletePrefixRegexp.test(prefix)) ? | 329 let actualPrefix = (!prefix || incompletePrefixRegexp.test(prefix)) ? |
330 prefix + "*" : prefix; | 330 prefix + "*" : prefix; |
331 | 331 |
332 let elements = scopedQuerySelectorAll(subtree, actualPrefix); | 332 let elements = scopedQuerySelectorAll(subtree, actualPrefix); |
| 333 |
333 if (elements) | 334 if (elements) |
334 { | 335 { |
| 336 let lastRoot = null; |
335 for (let element of elements) | 337 for (let element of elements) |
336 { | 338 { |
| 339 // For a filter like div:-abp-contains(Hello) and a subtree like |
| 340 // <div id="a"><div id="b"><div id="c">Hello</div></div></div> |
| 341 // we're only interested in div#a |
| 342 if (lastRoot && lastRoot.contains(element)) |
| 343 { |
| 344 yield null; |
| 345 continue; |
| 346 } |
| 347 |
| 348 lastRoot = element; |
| 349 |
337 if (this._regexp && this._regexp.test(element.textContent)) | 350 if (this._regexp && this._regexp.test(element.textContent)) |
338 yield element; | 351 yield element; |
339 else | 352 else |
340 yield null; | 353 yield null; |
341 } | 354 } |
342 } | 355 } |
343 } | 356 } |
344 }; | 357 }; |
345 | 358 |
346 function PropsSelector(propertyExpression) | 359 function PropsSelector(propertyExpression) |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 characterData: shouldObserveCharacterData(this.patterns), | 822 characterData: shouldObserveCharacterData(this.patterns), |
810 subtree: true | 823 subtree: true |
811 } | 824 } |
812 ); | 825 ); |
813 this.document.addEventListener("load", this.onLoad.bind(this), true); | 826 this.document.addEventListener("load", this.onLoad.bind(this), true); |
814 } | 827 } |
815 } | 828 } |
816 }; | 829 }; |
817 | 830 |
818 exports.ElemHideEmulation = ElemHideEmulation; | 831 exports.ElemHideEmulation = ElemHideEmulation; |
OLD | NEW |