Index: lib/content/elemHideEmulation.js |
=================================================================== |
--- a/lib/content/elemHideEmulation.js |
+++ b/lib/content/elemHideEmulation.js |
@@ -189,40 +189,49 @@ |
* @param {string} prefix the prefix for the selector. |
* @param {Node} subtree the subtree we work on. |
* @param {StringifiedStyle[]} styles the stringified style objects. |
*/ |
*getElements(prefix, subtree, styles) |
{ |
let actualPrefix = (!prefix || incompletePrefixRegexp.test(prefix)) ? |
prefix + "*" : prefix; |
- let elements = subtree.querySelectorAll(actualPrefix); |
- for (let element of elements) |
+ if (relativeSelectorRegexp.test(actualPrefix)) |
Manish Jethani
2018/01/23 16:42:11
If I understand this correctly, "+" and "~" don't
hub
2018/01/25 21:58:34
Done.
|
+ actualPrefix = ":scope" + actualPrefix; |
+ try |
{ |
- let iter = evaluate(this._innerSelectors, 0, "", element, styles); |
- for (let selector of iter) |
+ let elements = subtree.querySelectorAll(actualPrefix); |
lainverse
2018/01/23 01:02:51
As I understand if this fails it's still possible
Manish Jethani
2018/01/23 16:42:11
I agree this could probably be made to work on Edg
hub
2018/01/23 16:51:11
Filed https://issues.adblockplus.org/ticket/6304
|
+ for (let element of elements) |
{ |
- if (selector == null) |
+ let iter = evaluate(this._innerSelectors, 0, "", element, styles); |
+ for (let selector of iter) |
{ |
- yield null; |
- continue; |
+ if (selector == null) |
+ { |
+ yield null; |
+ continue; |
+ } |
+ if (relativeSelectorRegexp.test(selector)) |
Manish Jethani
2018/01/23 16:42:11
So this and the try..catch could be made generic a
hub
2018/01/25 21:58:34
This should allow us to fix issue #6304 more easil
|
+ selector = ":scope" + selector; |
+ try |
+ { |
+ if (element.querySelector(selector)) |
+ yield element; |
+ } |
+ catch (e) |
+ { |
+ // :scope isn't supported on Edge, ignore error caused by it. |
+ } |
} |
- if (relativeSelectorRegexp.test(selector)) |
- selector = ":scope" + selector; |
- try |
- { |
- if (element.querySelector(selector)) |
- yield element; |
- } |
- catch (e) |
- { |
- // :scope isn't supported on Edge, ignore error caused by it. |
- } |
+ yield null; |
} |
- yield null; |
+ } |
+ catch (e) |
+ { |
+ // :scope isn't supported on Edge, ignore error caused by it. |
} |
} |
}; |
function ContainsSelector(textContent) |
{ |
this._text = textContent; |
} |
@@ -235,24 +244,33 @@ |
for (let element of this.getElements(prefix, subtree, stylesheet)) |
yield [makeSelector(element, ""), subtree]; |
}, |
*getElements(prefix, subtree, stylesheet) |
{ |
let actualPrefix = (!prefix || incompletePrefixRegexp.test(prefix)) ? |
prefix + "*" : prefix; |
- let elements = subtree.querySelectorAll(actualPrefix); |
- |
- for (let element of elements) |
+ if (relativeSelectorRegexp.test(actualPrefix)) |
+ actualPrefix = ":scope" + actualPrefix; |
+ try |
{ |
- if (element.textContent.includes(this._text)) |
- yield element; |
- else |
- yield null; |
+ let elements = subtree.querySelectorAll(actualPrefix); |
+ |
+ for (let element of elements) |
+ { |
+ if (element.textContent.includes(this._text)) |
+ yield element; |
+ else |
+ yield null; |
+ } |
+ } |
+ catch (e) |
+ { |
+ // :scope isn't supported on Edge, ignore error caused by it. |
} |
} |
}; |
function PropsSelector(propertyExpression) |
{ |
let regexpString; |
if (propertyExpression.length >= 2 && propertyExpression[0] == "/" && |