Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: lib/content/elemHideEmulation.js

Issue 29728579: Issue 6437 - Apply :-abp-contains() to matching roots only (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Update tests Created April 19, 2018, 4:28 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/browser/elemHideEmulation.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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;
OLDNEW
« no previous file with comments | « no previous file | test/browser/elemHideEmulation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld