code review: no need to capture in regex

This commit is contained in:
gorhill 2015-11-05 09:19:45 -05:00
parent 5464dc2b9e
commit c99b61da96
1 changed files with 4 additions and 4 deletions

View File

@ -728,10 +728,10 @@ FilterContainer.prototype.compileGenericSelector = function(parsed, out) {
// Single-CSS rule: no need to test for whether the selector // Single-CSS rule: no need to test for whether the selector
// is valid, the regex took care of this. Most generic selector falls // is valid, the regex took care of this. Most generic selector falls
// into that category. // into that category.
if ( matches[1] === selector ) { if ( matches[0] === selector ) {
out.push( out.push(
'c\vlg\v' + 'c\vlg\v' +
matches[1] matches[0]
); );
return; return;
} }
@ -739,7 +739,7 @@ FilterContainer.prototype.compileGenericSelector = function(parsed, out) {
if ( this.isValidSelector(selector) ) { if ( this.isValidSelector(selector) ) {
out.push( out.push(
'c\vlg+\v' + 'c\vlg+\v' +
matches[1] + '\v' + matches[0] + '\v' +
selector selector
); );
} }
@ -774,7 +774,7 @@ FilterContainer.prototype.compileGenericSelector = function(parsed, out) {
}; };
FilterContainer.prototype.reClassOrIdSelector = /^([#.][\w-]+)$/; FilterContainer.prototype.reClassOrIdSelector = /^([#.][\w-]+)$/;
FilterContainer.prototype.rePlainSelector = /^([#.][\w-]+)/; FilterContainer.prototype.rePlainSelector = /^[#.][\w-]+/;
FilterContainer.prototype.reHighLow = /^[a-z]*\[(?:alt|title)="[^"]+"\]$/; FilterContainer.prototype.reHighLow = /^[a-z]*\[(?:alt|title)="[^"]+"\]$/;
FilterContainer.prototype.reHighMedium = /^\[href\^="https?:\/\/([^"]{8})[^"]*"\]$/; FilterContainer.prototype.reHighMedium = /^\[href\^="https?:\/\/([^"]{8})[^"]*"\]$/;