minor code review

This commit is contained in:
gorhill 2017-10-22 14:20:33 -04:00
parent ef84e6d8fd
commit 14109b33d6
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 6 additions and 6 deletions

View File

@ -98,20 +98,20 @@ var fromNetFilter = function(details) {
var fromCosmeticFilter = function(details) {
var match = /^#@?#/.exec(details.rawFilter),
prefix = match[0],
filter = details.rawFilter.slice(prefix.length),
selector = filter;
needle = details.rawFilter.slice(prefix.length),
selector = needle;
// With low generic simple cosmetic filters, the class or id prefix
// character is not part of the compiled data. So we must be ready to
// look-up version of the selector without the prefix character.
var idOrClassPrefix = filter.charAt(0),
var idOrClassPrefix = needle.charAt(0),
cssPrefixMatcher;
if ( idOrClassPrefix === '#' ) {
cssPrefixMatcher = '#?';
filter = filter.slice(1);
needle = needle.slice(1);
} else if ( idOrClassPrefix === '.' ) {
cssPrefixMatcher = '\\.?';
filter = filter.slice(1);
needle = needle.slice(1);
} else {
idOrClassPrefix = '';
cssPrefixMatcher = '';
@ -122,7 +122,7 @@ var fromCosmeticFilter = function(details) {
var reFilter = new RegExp(
'^\\[\\d,[^\\n]*\\\\*"' +
cssPrefixMatcher +
reEscapeCosmetic(filter) +
reEscapeCosmetic(needle) +
'\\\\*"[^\\n]*\\]$',
'gm'
);