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

Unified Diff: chrome/content/elemHideEmulation.js

Issue 29490698: Issue 5422 - Properly build props selector (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created July 17, 2017, 5:07 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 | no next file » | no next file with comments »
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
@@ -45,23 +45,23 @@
if (chr == '"' || chr == "'")
sep = chr;
else if (chr == "(") // don't split between parentheses
level++; // e.g. :matches(div,span)
else if (chr == ")")
level = Math.max(0, level - 1);
else if (chr == "," && level == 0)
{
- selectors.push(selector.substring(start, i));
+ selectors.push(selector.substring(start, i).trim());
start = i + 1;
}
}
}
- selectors.push(selector.substring(start));
+ selectors.push(selector.substring(start).trim());
return selectors;
}
/** Return position of node from parent.
* @param {Node} node the node to find the position of.
* @return {number} One-based index like for :nth-child(), or 0 on error.
*/
function positionInParent(node)
@@ -276,20 +276,26 @@
}
PropsSelector.prototype = {
preferHideWithSelector: true,
dependsOnStyles: true,
*findPropsSelectors(styles, prefix, regexp)
{
+ let actualPrefix = (prefix && !incompletePrefixRegexp.test(prefix)) ?
+ prefix + " " : prefix;
for (let style of styles)
if (regexp.test(style.style))
for (let subSelector of style.subSelectors)
- yield prefix + subSelector;
+ {
+ if (subSelector == "*")
+ subSelector = "";
+ yield actualPrefix + subSelector;
+ }
},
*getSelectors(prefix, subtree, styles)
{
for (let selector of this.findPropsSelectors(styles, prefix, this._regexp))
yield [selector, subtree];
}
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld