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

Delta Between Two Patch Sets: lib/common.js

Issue 30011555: Issue 7303 - Deprecate the use of String.prototype.substr() (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Rebase Created Feb. 21, 2019, 2:48 p.m.
Right Patch Set: Rebase. Revert changes in hot path. Created Feb. 21, 2019, 6:09 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/content/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 /* 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 { 199 {
200 sub = sub.trim(); 200 sub = sub.trim();
201 201
202 qualifiedSelector += ", "; 202 qualifiedSelector += ", ";
203 203
204 let index = findTargetSelectorIndex(sub); 204 let index = findTargetSelectorIndex(sub);
205 let [, type = "", rest] = /^([a-z][a-z-]*)?(.*)/i.exec(sub.substring(index)) ; 205 let [, type = "", rest] = /^([a-z][a-z-]*)?(.*)/i.exec(sub.substring(index)) ;
206 206
207 // Note that the first group in the regular expression is optional. If it 207 // Note that the first group in the regular expression is optional. If it
208 // doesn't match (e.g. "#foo::nth-child(1)"), type will be an empty string. 208 // doesn't match (e.g. "#foo::nth-child(1)"), type will be an empty string.
209 qualifiedSelector += sub.substring(0, index) + type + qualifier + rest; 209 // If `rest` is "*" then it is discarded.
210 qualifiedSelector += sub.substring(0, index) + type + qualifier +
211 (rest != "*" ? rest : "");
210 } 212 }
211 213
212 // Remove the initial comma and space. 214 // Remove the initial comma and space.
213 return qualifiedSelector.substring(2); 215 return qualifiedSelector.substring(2);
214 } 216 }
215 217
216 exports.qualifySelector = qualifySelector; 218 exports.qualifySelector = qualifySelector;
LEFTRIGHT

Powered by Google App Engine
This is Rietveld