mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
[mv3] Code review: matches is never empty
This commit is contained in:
parent
aa696d0669
commit
b2c9be14cf
1 changed files with 6 additions and 15 deletions
|
|
@ -142,12 +142,10 @@ function registerHighGeneric(context, genericDetails) {
|
||||||
const directive = {
|
const directive = {
|
||||||
id: 'css-generichigh',
|
id: 'css-generichigh',
|
||||||
css,
|
css,
|
||||||
|
matches,
|
||||||
allFrames: true,
|
allFrames: true,
|
||||||
runAt: 'document_end',
|
runAt: 'document_end',
|
||||||
};
|
};
|
||||||
if ( matches.length !== 0 ) {
|
|
||||||
directive.matches = matches;
|
|
||||||
}
|
|
||||||
if ( excludeMatches.length !== 0 ) {
|
if ( excludeMatches.length !== 0 ) {
|
||||||
directive.excludeMatches = excludeMatches;
|
directive.excludeMatches = excludeMatches;
|
||||||
}
|
}
|
||||||
|
|
@ -323,12 +321,10 @@ function registerProcedural(context) {
|
||||||
const directive = {
|
const directive = {
|
||||||
id: 'css-procedural',
|
id: 'css-procedural',
|
||||||
js,
|
js,
|
||||||
|
matches,
|
||||||
allFrames: true,
|
allFrames: true,
|
||||||
runAt: 'document_start',
|
runAt: 'document_start',
|
||||||
};
|
};
|
||||||
if ( matches.length !== 0 ) {
|
|
||||||
directive.matches = matches;
|
|
||||||
}
|
|
||||||
if ( excludeMatches.length !== 0 ) {
|
if ( excludeMatches.length !== 0 ) {
|
||||||
directive.excludeMatches = excludeMatches;
|
directive.excludeMatches = excludeMatches;
|
||||||
}
|
}
|
||||||
|
|
@ -389,12 +385,10 @@ function registerDeclarative(context) {
|
||||||
const directive = {
|
const directive = {
|
||||||
id: 'css-declarative',
|
id: 'css-declarative',
|
||||||
js,
|
js,
|
||||||
|
matches,
|
||||||
allFrames: true,
|
allFrames: true,
|
||||||
runAt: 'document_start',
|
runAt: 'document_start',
|
||||||
};
|
};
|
||||||
if ( matches.length !== 0 ) {
|
|
||||||
directive.matches = matches;
|
|
||||||
}
|
|
||||||
if ( excludeMatches.length !== 0 ) {
|
if ( excludeMatches.length !== 0 ) {
|
||||||
directive.excludeMatches = excludeMatches;
|
directive.excludeMatches = excludeMatches;
|
||||||
}
|
}
|
||||||
|
|
@ -455,12 +449,10 @@ function registerSpecific(context) {
|
||||||
const directive = {
|
const directive = {
|
||||||
id: 'css-specific',
|
id: 'css-specific',
|
||||||
js,
|
js,
|
||||||
|
matches,
|
||||||
allFrames: true,
|
allFrames: true,
|
||||||
runAt: 'document_start',
|
runAt: 'document_start',
|
||||||
};
|
};
|
||||||
if ( matches.length !== 0 ) {
|
|
||||||
directive.matches = matches;
|
|
||||||
}
|
|
||||||
if ( excludeMatches.length !== 0 ) {
|
if ( excludeMatches.length !== 0 ) {
|
||||||
directive.excludeMatches = excludeMatches;
|
directive.excludeMatches = excludeMatches;
|
||||||
}
|
}
|
||||||
|
|
@ -530,20 +522,19 @@ function registerScriptlet(context, scriptletDetails) {
|
||||||
}
|
}
|
||||||
if ( targetHostnames.length === 0 ) { continue; }
|
if ( targetHostnames.length === 0 ) { continue; }
|
||||||
matches.push(...ut.matchesFromHostnames(targetHostnames));
|
matches.push(...ut.matchesFromHostnames(targetHostnames));
|
||||||
|
normalizeMatches(matches);
|
||||||
|
|
||||||
before.delete(id); // Important!
|
before.delete(id); // Important!
|
||||||
|
|
||||||
const directive = {
|
const directive = {
|
||||||
id,
|
id,
|
||||||
js: [ `/rulesets/scripting/scriptlet/${id}.js` ],
|
js: [ `/rulesets/scripting/scriptlet/${id}.js` ],
|
||||||
|
matches,
|
||||||
allFrames: true,
|
allFrames: true,
|
||||||
matchOriginAsFallback: true,
|
matchOriginAsFallback: true,
|
||||||
runAt: 'document_start',
|
runAt: 'document_start',
|
||||||
world: details.world,
|
world: details.world,
|
||||||
};
|
};
|
||||||
if ( matches.length !== 0 ) {
|
|
||||||
directive.matches = matches;
|
|
||||||
}
|
|
||||||
if ( excludeMatches.length !== 0 ) {
|
if ( excludeMatches.length !== 0 ) {
|
||||||
directive.excludeMatches = excludeMatches;
|
directive.excludeMatches = excludeMatches;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue