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

Delta Between Two Patch Sets: lib/elemHide.js

Issue 29342837: Issue 4054 - Remove filters from filtersByDomain (Closed)
Left Patch Set: Use for ... in Created May 20, 2016, 1:12 p.m.
Right Patch Set: Rename domainMatches for consistency Created May 20, 2016, 1:30 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 | no next file » | 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 file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 let key; 150 let key;
151 do { 151 do {
152 key = Math.random().toFixed(15).substr(5); 152 key = Math.random().toFixed(15).substr(5);
153 } while (key in filterByKey); 153 } while (key in filterByKey);
154 154
155 filterByKey[key] = filter; 155 filterByKey[key] = filter;
156 keyByFilter[filter.text] = key; 156 keyByFilter[filter.text] = key;
157 157
158 if (usingFiltersByDomain) 158 if (usingFiltersByDomain)
159 { 159 {
160 let domainMatches = filter.domains || defaultDomains; 160 let domains = filter.domains || defaultDomains;
161 for (let domain in domainMatches) 161 for (let domain in domains)
162 { 162 {
163 let filters = filtersByDomain[domain]; 163 let filters = filtersByDomain[domain];
164 if (!filters) 164 if (!filters)
165 filters = filtersByDomain[domain] = Object.create(null); 165 filters = filtersByDomain[domain] = Object.create(null);
166 166
167 if (domainMatches[domain]) 167 if (domains[domain])
168 filters[filter.text] = filter; 168 filters[filter.text] = filter;
169 else 169 else
170 filters[filter.text] = false; 170 filters[filter.text] = false;
171 } 171 }
172 } 172 }
173 173
174 ElemHide.isDirty = true; 174 ElemHide.isDirty = true;
175 } 175 }
176 }, 176 },
177 177
(...skipping 19 matching lines...) Expand all
197 if (!(filter.text in keyByFilter)) 197 if (!(filter.text in keyByFilter))
198 return; 198 return;
199 199
200 let key = keyByFilter[filter.text]; 200 let key = keyByFilter[filter.text];
201 delete filterByKey[key]; 201 delete filterByKey[key];
202 delete keyByFilter[filter.text]; 202 delete keyByFilter[filter.text];
203 ElemHide.isDirty = true; 203 ElemHide.isDirty = true;
204 204
205 if (usingFiltersByDomain) 205 if (usingFiltersByDomain)
206 { 206 {
207 let domains = filter.domains || defaultDomains; 207 let domains = filter.domains || defaultDomains;
Wladimir Palant 2016/05/20 13:26:06 The same variable is named domainMatches in .add()
kzar 2016/05/20 13:31:23 Done.
208 for (let domain in domains) 208 for (let domain in domains)
209 { 209 {
210 let filters = filtersByDomain[domain]; 210 let filters = filtersByDomain[domain];
211 if (filters) 211 if (filters)
212 delete filters[filter.text]; 212 delete filters[filter.text];
213 } 213 }
214 } 214 }
215 } 215 }
216 }, 216 },
217 217
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 if (currentDomain == "") 451 if (currentDomain == "")
452 break; 452 break;
453 453
454 let nextDot = currentDomain.indexOf("."); 454 let nextDot = currentDomain.indexOf(".");
455 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1); 455 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1);
456 } 456 }
457 457
458 return selectors; 458 return selectors;
459 } 459 }
460 }; 460 };
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld