OLD | NEW |
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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // If we're already within a parenthesis, close the scope. | 142 // If we're already within a parenthesis, close the scope. |
143 if (currentScope == ")") | 143 if (currentScope == ")") |
144 scope.pop(); | 144 scope.pop(); |
145 } | 145 } |
146 else if (!currentScope) | 146 else if (!currentScope) |
147 { | 147 { |
148 // At the top level (not within any scope), count the whitespace if we've | 148 // At the top level (not within any scope), count the whitespace if we've |
149 // encountered it. Otherwise if we've hit one of the combinators, | 149 // encountered it. Otherwise if we've hit one of the combinators, |
150 // terminate here; otherwise if we've hit a non-colon character, | 150 // terminate here; otherwise if we've hit a non-colon character, |
151 // terminate here. | 151 // terminate here. |
152 if (/\s/u.test(character)) | 152 if (/\s/.test(character)) |
153 { | 153 { |
154 whitespace++; | 154 whitespace++; |
155 } | 155 } |
156 else if ((character == ">" || character == "+" || character == "~") || | 156 else if ((character == ">" || character == "+" || character == "~") || |
157 (whitespace > 0 && character != ":")) | 157 (whitespace > 0 && character != ":")) |
158 { | 158 { |
159 break; | 159 break; |
160 } | 160 } |
161 } | 161 } |
162 | 162 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 // Note that the first group in the regular expression is optional. If it | 196 // Note that the first group in the regular expression is optional. If it |
197 // doesn't match (e.g. "#foo::nth-child(1)"), type will be an empty string. | 197 // doesn't match (e.g. "#foo::nth-child(1)"), type will be an empty string. |
198 qualifiedSelector += sub.substr(0, index) + type + qualifier + rest; | 198 qualifiedSelector += sub.substr(0, index) + type + qualifier + rest; |
199 } | 199 } |
200 | 200 |
201 // Remove the initial comma and space. | 201 // Remove the initial comma and space. |
202 return qualifiedSelector.substr(2); | 202 return qualifiedSelector.substr(2); |
203 } | 203 } |
204 | 204 |
205 exports.qualifySelector = qualifySelector; | 205 exports.qualifySelector = qualifySelector; |
OLD | NEW |