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

Side by Side Diff: lib/elemHide.js

Issue 29807560: Issue 6745 - Prefer strict equality operator (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created June 14, 2018, 4:11 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 | « lib/downloader.js ('k') | lib/events.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 file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 /** 68 /**
69 * Adds a filter to the lookup table of filters by domain. 69 * Adds a filter to the lookup table of filters by domain.
70 * @param {Filter} filter 70 * @param {Filter} filter
71 */ 71 */
72 function addToFiltersByDomain(filter) 72 function addToFiltersByDomain(filter)
73 { 73 {
74 let domains = filter.domains || defaultDomains; 74 let domains = filter.domains || defaultDomains;
75 for (let [domain, isIncluded] of domains) 75 for (let [domain, isIncluded] of domains)
76 { 76 {
77 // There's no need to note that a filter is generically disabled. 77 // There's no need to note that a filter is generically disabled.
78 if (!isIncluded && domain == "") 78 if (!isIncluded && domain === "")
79 continue; 79 continue;
80 80
81 let filters = filtersByDomain.get(domain); 81 let filters = filtersByDomain.get(domain);
82 if (!filters) 82 if (!filters)
83 filtersByDomain.set(domain, filters = new Map()); 83 filtersByDomain.set(domain, filters = new Map());
84 filters.set(filter, isIncluded); 84 filters.set(filter, isIncluded);
85 } 85 }
86 } 86 }
87 87
88 /** 88 /**
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 // Whitelisting filters 173 // Whitelisting filters
174 if (filter instanceof ElemHideException) 174 if (filter instanceof ElemHideException)
175 { 175 {
176 let list = exceptions.get(filter.selector); 176 let list = exceptions.get(filter.selector);
177 let index = list.indexOf(filter); 177 let index = list.indexOf(filter);
178 if (index >= 0) 178 if (index >= 0)
179 list.splice(index, 1); 179 list.splice(index, 1);
180 } 180 }
181 // Unconditially applied element hiding filters 181 // Unconditially applied element hiding filters
182 else if (filterBySelector.get(filter.selector) == filter) 182 else if (filterBySelector.get(filter.selector) === filter)
183 { 183 {
184 filterBySelector.delete(filter.selector); 184 filterBySelector.delete(filter.selector);
185 unconditionalSelectors = null; 185 unconditionalSelectors = null;
186 } 186 }
187 // Conditionally applied element hiding filters 187 // Conditionally applied element hiding filters
188 else 188 else
189 { 189 {
190 let domains = filter.domains || defaultDomains; 190 let domains = filter.domains || defaultDomains;
191 for (let domain of domains.keys()) 191 for (let domain of domains.keys())
192 { 192 {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 { 233 {
234 let selectors = []; 234 let selectors = [];
235 235
236 let excluded = new Set(); 236 let excluded = new Set();
237 let currentDomain = domain ? domain.replace(/\.+$/, "").toUpperCase() : ""; 237 let currentDomain = domain ? domain.replace(/\.+$/, "").toUpperCase() : "";
238 238
239 // This code is a performance hot-spot, which is why we've made certain 239 // This code is a performance hot-spot, which is why we've made certain
240 // micro-optimisations. Please be careful before making changes. 240 // micro-optimisations. Please be careful before making changes.
241 while (true) 241 while (true)
242 { 242 {
243 if (specificOnly && currentDomain == "") 243 if (specificOnly && currentDomain === "")
244 break; 244 break;
245 245
246 let filters = filtersByDomain.get(currentDomain); 246 let filters = filtersByDomain.get(currentDomain);
247 if (filters) 247 if (filters)
248 { 248 {
249 for (let [filter, isIncluded] of filters) 249 for (let [filter, isIncluded] of filters)
250 { 250 {
251 if (!isIncluded) 251 if (!isIncluded)
252 { 252 {
253 excluded.add(filter); 253 excluded.add(filter);
254 } 254 }
255 else if ((excluded.size == 0 || !excluded.has(filter)) && 255 else if ((excluded.size === 0 || !excluded.has(filter)) &&
256 !this.getException(filter, domain)) 256 !this.getException(filter, domain))
257 { 257 {
258 selectors.push(filter.selector); 258 selectors.push(filter.selector);
259 } 259 }
260 } 260 }
261 } 261 }
262 262
263 if (currentDomain == "") 263 if (currentDomain === "")
264 break; 264 break;
265 265
266 let nextDot = currentDomain.indexOf("."); 266 let nextDot = currentDomain.indexOf(".");
267 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1); 267 currentDomain = nextDot === -1 ? "" : currentDomain.substr(nextDot + 1);
268 } 268 }
269 269
270 if (!specificOnly) 270 if (!specificOnly)
271 selectors = getUnconditionalSelectors().concat(selectors); 271 selectors = getUnconditionalSelectors().concat(selectors);
272 272
273 return selectors; 273 return selectors;
274 } 274 }
275 }; 275 };
OLDNEW
« no previous file with comments | « lib/downloader.js ('k') | lib/events.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld