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: Rebased on master Created July 19, 2017, 2:35 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
@@ -44,23 +44,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)
@@ -268,20 +268,26 @@
this._regexp = new RegExp(regexpString, "i");
}
PropsSelector.prototype = {
preferHideWithSelector: true,
*findPropsSelectors(styles, prefix, regexp)
{
+ let actualPrefix = (prefix && !incompletePrefixRegexp.test(prefix)) ?
+ prefix + " " : prefix;
Wladimir Palant 2017/08/16 08:37:02 No, this is not what we want. Consider .abp-testsu
hub 2017/08/16 19:50:32 Acknowledged.
for (let style of styles)
if (regexp.test(style.style))
for (let subSelector of style.subSelectors)
- yield prefix + subSelector;
+ {
+ if (subSelector == "*")
+ subSelector = "";
Wladimir Palant 2017/08/16 08:37:02 What if we have a filter like `:-abp-properties(fo
hub 2017/08/16 19:50:32 Done.
+ 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