1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-15 07:22:28 +02:00

Fix test for stylesheet presence

Related commit:
- 4f923384de
This commit is contained in:
Raymond Hill 2021-10-27 15:13:13 -04:00
parent 6722616e28
commit 97a33c9572
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -1442,13 +1442,16 @@ Parser.prototype.SelectorCompiler = class {
// https://github.com/gorhill/uBlock/issues/3111
// Workaround until https://bugzilla.mozilla.org/show_bug.cgi?id=1406817
// is fixed.
// https://github.com/uBlockOrigin/uBlock-issues/issues/1751
// Do not rely on matches() or querySelector() to test whether a
// selector is declarative or not.
cssSelectorType(s) {
if ( this.reSimpleSelector.test(s) ) { return 1; }
const pos = this.cssPseudoElement(s);
if ( pos !== -1 ) {
return this.cssSelectorType(s.slice(0, pos)) === 1 ? 3 : 0;
}
if ( this.div === null ) { return 1; }
if ( this.stylesheet === null ) { return 1; }
try {
this.stylesheet.insertRule(`${s}{color:red}`);
if ( this.stylesheet.cssRules.length === 0 ) { return 0; }