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

Unified 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.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/browser/elemHideEmulation.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/content/elemHideEmulation.js
===================================================================
--- a/lib/content/elemHideEmulation.js
+++ b/lib/content/elemHideEmulation.js
@@ -322,20 +322,33 @@
},
*getElements(prefix, subtree, styles)
{
let actualPrefix = (!prefix || incompletePrefixRegexp.test(prefix)) ?
prefix + "*" : prefix;
let elements = scopedQuerySelectorAll(subtree, actualPrefix);
+
if (elements)
{
+ let lastRoot = null;
for (let element of elements)
{
+ // For a filter like div:-abp-contains(Hello) and a subtree like
+ // <div id="a"><div id="b"><div id="c">Hello</div></div></div>
+ // we're only interested in div#a
+ if (lastRoot && lastRoot.contains(element))
+ {
+ yield null;
+ continue;
+ }
+
+ lastRoot = element;
+
if (this._regexp && this._regexp.test(element.textContent))
yield element;
else
yield null;
}
}
}
};
« 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