Skip to content

Commit

Permalink
use modifier only once
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 10, 2015
1 parent 03cfe7d commit a916d3f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/Mojo/DOM/CSS.pm
Expand Up @@ -279,24 +279,24 @@ sub _unescape {
}

sub _value {
my ($op, $value, $ci) = @_;
my ($op, $value, $insensitive) = @_;
return undef unless defined $value;
$value = quotemeta _unescape($value);
$value = ($insensitive ? '(?i)' : '') . quotemeta _unescape($value);

# "~=" (word)
return qr/@{[$ci ? '(?i)' : '']}(?:^|.*\s+)$value(?:\s+.*|$)/ if $op eq '~';
return qr/(?:^|.*\s+)$value(?:\s+.*|$)/ if $op eq '~';

# "*=" (contains)
return qr/@{[$ci ? '(?i)' : '']}$value/ if $op eq '*';
return qr/$value/ if $op eq '*';

# "^=" (begins with)
return qr/@{[$ci ? '(?i)' : '']}^$value/ if $op eq '^';
return qr/^$value/ if $op eq '^';

# "$=" (ends with)
return qr/@{[$ci ? '(?i)' : '']}$value$/ if $op eq '$';
return qr/$value$/ if $op eq '$';

# Everything else
return qr/@{[$ci ? '(?i)' : '']}^$value$/;
return qr/^$value$/;
}

1;
Expand Down

0 comments on commit a916d3f

Please sign in to comment.