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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 * @param {Node} subtree the subtree we work on. | 217 * @param {Node} subtree the subtree we work on. |
218 * @param {StringifiedStyle[]} styles the stringified style objects. | 218 * @param {StringifiedStyle[]} styles the stringified style objects. |
219 */ | 219 */ |
220 *getElements(prefix, subtree, styles) | 220 *getElements(prefix, subtree, styles) |
221 { | 221 { |
222 let actualPrefix = (!prefix || incompletePrefixRegexp.test(prefix)) ? | 222 let actualPrefix = (!prefix || incompletePrefixRegexp.test(prefix)) ? |
223 prefix + "*" : prefix; | 223 prefix + "*" : prefix; |
224 let elements = subtree.querySelectorAll(actualPrefix); | 224 let elements = subtree.querySelectorAll(actualPrefix); |
225 for (let element of elements) | 225 for (let element of elements) |
226 { | 226 { |
227 let newPrefix = makeSelector(element, ""); | 227 let iter = evaluate(this._innerSelectors, 0, "", element, styles); |
228 let iter = evaluate(this._innerSelectors, 0, newPrefix + " ", | |
229 element, styles); | |
230 for (let selector of iter) | 228 for (let selector of iter) |
231 // we insert a space between the two. It becomes a no-op if selector | 229 if (element.querySelector(selector)) |
232 // doesn't have a combinator | |
233 if (subtree.querySelector(selector)) | |
234 yield element; | 230 yield element; |
235 } | 231 } |
236 } | 232 } |
237 }; | 233 }; |
238 | 234 |
239 function PropsSelector(propertyExpression) | 235 function PropsSelector(propertyExpression) |
240 { | 236 { |
241 let regexpString; | 237 let regexpString; |
242 if (propertyExpression.length >= 2 && propertyExpression[0] == "/" && | 238 if (propertyExpression.length >= 2 && propertyExpression[0] == "/" && |
243 propertyExpression[propertyExpression.length - 1] == "/") | 239 propertyExpression[propertyExpression.length - 1] == "/") |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 | 464 |
469 if (this.patterns.length > 0) | 465 if (this.patterns.length > 0) |
470 { | 466 { |
471 let {document} = this.window; | 467 let {document} = this.window; |
472 this.addSelectors(); | 468 this.addSelectors(); |
473 document.addEventListener("load", this.onLoad.bind(this), true); | 469 document.addEventListener("load", this.onLoad.bind(this), true); |
474 } | 470 } |
475 }); | 471 }); |
476 } | 472 } |
477 }; | 473 }; |
OLD | NEW |