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

Unified Diff: chrome/content/elemHideEmulation.js

Issue 29372676: [adblockpluscore] Issue 4825 - Let ElemHideEmulation associate selector and filter when calling add… (Closed)
Patch Set: Use map instead of object Created Feb. 7, 2017, 11:56 a.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
diff --git a/chrome/content/elemHideEmulation.js b/chrome/content/elemHideEmulation.js
index 95a4c5d4ba314ce0c5697c626e52e62edbde574c..3ea1ab7079058edc555b3c31b4ac6bb81c2912e1 100644
--- a/chrome/content/elemHideEmulation.js
+++ b/chrome/content/elemHideEmulation.js
@@ -73,7 +73,7 @@ ElemHideEmulation.prototype = {
}
},
- findSelectors: function(stylesheet, selectors, filters)
+ findSelectors: function(stylesheet, filters)
{
// Explicitly ignore third-party stylesheets to ensure consistent behavior
// between Firefox and Chrome.
@@ -97,9 +97,14 @@ ElemHideEmulation.prototype = {
if (pattern.regexp.test(style))
{
var subSelectors = splitSelector(rule.selectorText);
+ var selectors = [];
+
for (var k = 0; k < subSelectors.length; k++)
selectors.push(pattern.prefix + subSelectors[k] + pattern.suffix);
- filters[pattern.text] = true;
+
+ if (!filters.has(pattern.text))
+ filters.set(pattern.text, []);
+ Array.prototype.push.apply(filters.get(pattern.text), selectors);
Sebastian Noack 2017/02/07 12:35:59 Creating a temporary array, just to merge it with
wspee 2017/02/07 14:15:08 Done.
}
}
}
@@ -107,11 +112,10 @@ ElemHideEmulation.prototype = {
addSelectors: function(stylesheets)
{
- var selectors = [];
- var filters = {};
+ var filters = new Map();
for (var i = 0; i < stylesheets.length; i++)
- this.findSelectors(stylesheets[i], selectors, filters);
- this.addSelectorsFunc(selectors, Object.keys(filters));
+ this.findSelectors(stylesheets[i], filters);
+ this.addSelectorsFunc(filters);
},
onLoad: function(event)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld