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

Side by Side Diff: chrome/content/composer.js

Issue 6520005931827200: Issue 2259 - Removed non-standard JavaScript code from Element Hiding Helper (Closed)
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:
View unified diff | Download patch
« no previous file with comments | « no previous file | lib/aardvark.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 }; 94 };
95 } 95 }
96 96
97 function createPropertyProxy(obj, orig, key) { 97 function createPropertyProxy(obj, orig, key) {
98 if (typeof orig[key] == "function") { 98 if (typeof orig[key] == "function") {
99 obj[key] = function() { 99 obj[key] = function() {
100 return orig[key].apply(orig, arguments); 100 return orig[key].apply(orig, arguments);
101 }; 101 };
102 } 102 }
103 else { 103 else {
104 obj.__defineGetter__(key, function() { 104 Object.defineProperty(obj, key, {
105 return orig[key]; 105 get: () => orig[key],
106 }); 106 set: value => { orig[key] = value; },
107 obj.__defineSetter__(key, function(value) { 107 enumerable: true
108 orig[key] = value;
109 }); 108 });
110 } 109 }
111 } 110 }
112 111
113 function TreeView_getRowProperties(row) { 112 function TreeView_getRowProperties(row) {
114 let properties = "selected-" + this.selection.isSelected(row); 113 let properties = "selected-" + this.selection.isSelected(row);
115 114
116 var item = this.getItemAtIndex(row); 115 var item = this.getItemAtIndex(row);
117 if (item && (item.nodeData.expression != "*" || item.nodeData == nodeData)) 116 if (item && (item.nodeData.expression != "*" || item.nodeData == nodeData))
118 properties += " anchor"; 117 properties += " anchor";
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 else if (attr.value.substr(0, attr.selected.length) == attr.selected) 241 else if (attr.value.substr(0, attr.selected.length) == attr.selected)
243 op = "^="; 242 op = "^=";
244 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)
245 op = "$="; 244 op = "$=";
246 245
247 let useFallback = false; 246 let useFallback = false;
248 if (attr.name == "id" && op == "=") 247 if (attr.name == "id" && op == "=")
249 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);
250 else if (attr.name == "class" && /\S/.test(attr.selected)) 249 else if (attr.name == "class" && /\S/.test(attr.selected))
251 { 250 {
252 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
253 for each (let cls in attr.value.split(/\s+/)) 252 let classes = attr.selected.split(/\s+/).filter(cls => cls != "");
254 knownClasses[cls] = true; 253 if (classes.every(cls => knownClasses.has(cls)))
255
256 let classes = attr.selected.split(/\s+/).filter(function(cls) cls != "");
257 if (classes.every(function(cls) knownClasses.hasOwnProperty(cls)))
258 expression += "." + classes.map(escapeName).join("."); 254 expression += "." + classes.map(escapeName).join(".");
259 else 255 else
260 useFallback = true; 256 useFallback = true;
261 } 257 }
262 else 258 else
263 useFallback = true; 259 useFallback = true;
264 260
265 if (useFallback) 261 if (useFallback)
266 { 262 {
267 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
632 628
633 fillAttributes(item.nodeData); 629 fillAttributes(item.nodeData);
634 } 630 }
635 631
636 function addExpression() 632 function addExpression()
637 { 633 {
638 AdblockPlus.addPatterns([document.getElementById("expression").value]); 634 AdblockPlus.addPatterns([document.getElementById("expression").value]);
639 635
640 togglePreview(false); 636 togglePreview(false);
641 } 637 }
OLDNEW
« no previous file with comments | « no previous file | lib/aardvark.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld