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

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

Issue 6520005931827200: Issue 2259 - Removed non-standard JavaScript code from Element Hiding Helper (Closed)
Left Patch Set: Created April 1, 2015, 3:16 p.m.
Right Patch Set: Turned knownClasses into a Set as well Created April 4, 2015, 3:28 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 | lib/aardvark.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 /* 1 /*
2 * This Source Code is subject to the terms of the Mozilla Public License 2 * This Source Code is subject to the terms of the Mozilla Public License
3 * version 2.0 (the "License"). You can obtain a copy of the License at 3 * version 2.0 (the "License"). You can obtain a copy of the License at
4 * http://mozilla.org/MPL/2.0/. 4 * http://mozilla.org/MPL/2.0/.
5 */ 5 */
6 6
7 let {Prefs} = require("prefs"); 7 let {Prefs} = require("prefs");
8 8
9 let domainData; 9 let domainData;
10 let nodeData; 10 let nodeData;
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 else if (attr.value.substr(0, attr.selected.length) == attr.selected) 241 else if (attr.value.substr(0, attr.selected.length) == attr.selected)
242 op = "^="; 242 op = "^=";
243 else if (attr.value.substr(attr.value.length - attr.selected.length) = = attr.selected) 243 else if (attr.value.substr(attr.value.length - attr.selected.length) = = attr.selected)
244 op = "$="; 244 op = "$=";
245 245
246 let useFallback = false; 246 let useFallback = false;
247 if (attr.name == "id" && op == "=") 247 if (attr.name == "id" && op == "=")
248 expression += "#" + escapeName(attr.selected).replace(/^([^a-zA-Z\\] )/, escapeChar).replace(/\\(\s)$/, escapeChar); 248 expression += "#" + escapeName(attr.selected).replace(/^([^a-zA-Z\\] )/, escapeChar).replace(/\\(\s)$/, escapeChar);
249 else if (attr.name == "class" && /\S/.test(attr.selected)) 249 else if (attr.name == "class" && /\S/.test(attr.selected))
250 { 250 {
251 let knownClasses = {}; 251 let knownClasses = new Set(attr.value.split(/\s+/));
Sebastian Noack 2015/04/04 15:30:21 While introducing Sets and changing this code anyw
252 for (let cls of attr.value.split(/\s+/))
253 knownClasses[cls] = true;
254
255 let classes = attr.selected.split(/\s+/).filter(cls => cls != ""); 252 let classes = attr.selected.split(/\s+/).filter(cls => cls != "");
256 if (classes.every(cls => knownClasses.hasOwnProperty(cls))) 253 if (classes.every(cls => knownClasses.has(cls)))
257 expression += "." + classes.map(escapeName).join("."); 254 expression += "." + classes.map(escapeName).join(".");
258 else 255 else
259 useFallback = true; 256 useFallback = true;
260 } 257 }
261 else 258 else
262 useFallback = true; 259 useFallback = true;
263 260
264 if (useFallback) 261 if (useFallback)
265 { 262 {
266 var escapedValue = attr.selected.replace(/(["\\])/g, '\\$1') 263 var escapedValue = attr.selected.replace(/(["\\])/g, '\\$1')
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 628
632 fillAttributes(item.nodeData); 629 fillAttributes(item.nodeData);
633 } 630 }
634 631
635 function addExpression() 632 function addExpression()
636 { 633 {
637 AdblockPlus.addPatterns([document.getElementById("expression").value]); 634 AdblockPlus.addPatterns([document.getElementById("expression").value]);
638 635
639 togglePreview(false); 636 togglePreview(false);
640 } 637 }
LEFTRIGHT
« no previous file | lib/aardvark.js » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld