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

Delta Between Two Patch Sets: chrome/content/elemHideEmulation.js

Issue 29378674: Issue 4962 - Fix the tests.- Fix syntax in chrome/content/elemHideEmulation.js to use ES5Regress… (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Left Patch Set: formatting fixes Created March 8, 2017, 12:42 a.m.
Right Patch Set: changes following feedback Created March 8, 2017, 1:35 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | test/browser/elemHideEmulation.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // We are currently limited to ECMAScript 5 in this file, because it is being 1 // We are currently limited to ECMAScript 5 in this file, because it is being
2 // used in the browser tests. See https://issues.adblockplus.org/ticket/4796 2 // used in the browser tests. See https://issues.adblockplus.org/ticket/4796
3 3
4 var propertySelectorRegExp = /\[\-abp\-properties=(["'])([^"']+)\1\]/; 4 var propertySelectorRegExp = /\[\-abp\-properties=(["'])([^"']+)\1\]/;
5 5
6 function splitSelector(selector) 6 function splitSelector(selector)
7 { 7 {
8 if (selector.indexOf(",") == -1) 8 if (selector.indexOf(",") == -1)
9 return [selector]; 9 return [selector];
10 10
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 if (!rules) 87 if (!rules)
88 return; 88 return;
89 89
90 for (var i = 0; i < rules.length; i++) 90 for (var i = 0; i < rules.length; i++)
91 { 91 {
92 var rule = rules[i]; 92 var rule = rules[i];
93 if (rule.type != rule.STYLE_RULE) 93 if (rule.type != rule.STYLE_RULE)
94 continue; 94 continue;
95 95
96 var style = this.stringifyStyle(rule.style); 96 var style = this.stringifyStyle(rule.style);
97 this.patterns.forEach(function(pattern) 97 for (var j = 0; j < this.patterns.length; j++)
Wladimir Palant 2017/03/08 10:31:50 Last I checked, calling forEach caused suboptimal
98 { 98 {
99 var pattern = this.patterns[j];
99 if (pattern.regexp.test(style)) 100 if (pattern.regexp.test(style))
100 { 101 {
101 var subSelectors = splitSelector(rule.selectorText); 102 var subSelectors = splitSelector(rule.selectorText);
102 subSelectors.forEach(function(subSelector) 103 for (var k = 0; k < subSelectors.length; k++)
103 { 104 {
105 var subSelector = subSelectors[k];
104 selectors.push(pattern.prefix + subSelector + pattern.suffix); 106 selectors.push(pattern.prefix + subSelector + pattern.suffix);
105 filters.push(pattern.text); 107 filters.push(pattern.text);
106 }); 108 }
107 } 109 }
108 }); 110 }
109 } 111 }
110 }, 112 },
111 113
112 addSelectors: function(stylesheets) 114 addSelectors: function(stylesheets)
113 { 115 {
114 var selectors = []; 116 var selectors = [];
115 var filters = []; 117 var filters = [];
116 for (var i = 0; i < stylesheets.length; i++) 118 for (var i = 0; i < stylesheets.length; i++)
117 this.findSelectors(stylesheets[i], selectors, filters); 119 this.findSelectors(stylesheets[i], selectors, filters);
118 this.addSelectorsFunc(selectors, filters); 120 this.addSelectorsFunc(selectors, filters);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 158
157 if (this.patterns.length > 0) 159 if (this.patterns.length > 0)
158 { 160 {
159 var document = this.window.document; 161 var document = this.window.document;
160 this.addSelectors(document.styleSheets); 162 this.addSelectors(document.styleSheets);
161 document.addEventListener("load", this.onLoad.bind(this), true); 163 document.addEventListener("load", this.onLoad.bind(this), true);
162 } 164 }
163 }.bind(this)); 165 }.bind(this));
164 } 166 }
165 }; 167 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld