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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 { | 195 { |
196 let qualifiedSelector = ""; | 196 let qualifiedSelector = ""; |
197 | 197 |
198 for (let sub of splitSelector(selector)) | 198 for (let sub of splitSelector(selector)) |
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(inde
x)); |
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 // If `rest` is "*" then it is discarded. | 209 qualifiedSelector += sub.substring(0, index) + type + qualifier + rest; |
210 qualifiedSelector += sub.substring(0, index) + type + qualifier + | |
211 (rest != "*" ? rest : ""); | |
212 } | 210 } |
213 | 211 |
214 // Remove the initial comma and space. | 212 // Remove the initial comma and space. |
215 return qualifiedSelector.substring(2); | 213 return qualifiedSelector.substring(2); |
216 } | 214 } |
217 | 215 |
218 exports.qualifySelector = qualifySelector; | 216 exports.qualifySelector = qualifySelector; |
OLD | NEW |