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

Unified Diff: chrome/content/elemHideEmulation.js

Issue 29493648: Issue 5436 - Allow relative selectors in :-abp-has() (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Forgot a small cleanup change Created July 20, 2017, 7:21 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') | test/browser/elemHideEmulation.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/content/elemHideEmulation.js
===================================================================
--- a/chrome/content/elemHideEmulation.js
+++ b/chrome/content/elemHideEmulation.js
@@ -186,16 +186,17 @@
*/
*getSelectors(prefix, subtree, styles)
{
yield [prefix + this._selector, subtree];
}
};
const incompletePrefixRegexp = /[\s>+~]$/;
+const relativeSelectorRegexp = /^[\s>+~]/;
Wladimir Palant 2017/08/10 13:42:17 \s doesn't belong in here.
hub 2017/08/14 14:25:32 Done.
function HasSelector(selectors)
{
this._innerSelectors = selectors;
}
HasSelector.prototype = {
requiresHiding: true,
@@ -221,18 +222,22 @@
{
let actualPrefix = (!prefix || incompletePrefixRegexp.test(prefix)) ?
prefix + "*" : prefix;
let elements = subtree.querySelectorAll(actualPrefix);
for (let element of elements)
{
let iter = evaluate(this._innerSelectors, 0, "", element, styles);
for (let selector of iter)
+ {
+ if (relativeSelectorRegexp.test(selector))
+ selector = ":scope" + selector;
Wladimir Palant 2017/08/10 13:36:08 Nice one, I didn't know about :scope yet. Browser
hub 2017/08/14 14:25:32 Good point. Will catch the exception. I'll see if
if (element.querySelector(selector))
yield element;
+ }
}
}
};
function PropsSelector(propertyExpression)
{
let regexpString;
if (propertyExpression.length >= 2 && propertyExpression[0] == "/" &&
« no previous file with comments | « no previous file | test/browser/elemHideEmulation.js » ('j') | test/browser/elemHideEmulation.js » ('J')

Powered by Google App Engine
This is Rietveld