-
-
Save anonymous/359099cc3239e56d4101 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Mojo/DOM/CSS.pm b/lib/Mojo/DOM/CSS.pm | |
index 45d9ee2..c46827f 100644 | |
--- a/lib/Mojo/DOM/CSS.pm | |
+++ b/lib/Mojo/DOM/CSS.pm | |
@@ -10,7 +10,8 @@ my $ATTR_RE = qr/ | |
(?: | |
(\W)? # Operator | |
= | |
- (?:"((?:\\"|[^"])*)"|([^\]]+)) # Value | |
+ (?:"((?:\\"|[^"])*)"|([^\]]+?)) # Value | |
+ (?:\s+(i))? # Case-insensitive | |
)? | |
\] | |
/x; | |
@@ -82,7 +83,7 @@ sub _compile { | |
my $pattern = [[]]; | |
while ($css =~ /$TOKEN_RE/go) { | |
my ($separator, $element, $pc, $attrs, $combinator) | |
- = ($1, $2 // '', $3, $6, $11); | |
+ = ($1, $2 // '', $3, $6, $12); | |
next unless $separator || $element || $pc || $attrs || $combinator; | |
@@ -109,7 +110,7 @@ sub _compile { | |
while $pc =~ /$PSEUDO_CLASS_RE/go; | |
# Attributes | |
- push @$selector, ['attr', _name($1), _value($2 // '', $3 // $4)] | |
+ push @$selector, ['attr', _name($1), _value($2 // '', $3 // $4, $5)] | |
while $attrs =~ /$ATTR_RE/go; | |
# Combinator | |
@@ -279,7 +280,7 @@ sub _unescape { | |
} | |
sub _value { | |
- my ($op, $value) = @_; | |
+ my ($op, $value, $ci) = @_; | |
return undef unless defined $value; | |
$value = quotemeta _unescape($value); | |
@@ -296,7 +297,7 @@ sub _value { | |
return qr/$value$/ if $op eq '$'; | |
# Everything else | |
- return qr/^$value$/; | |
+ return $ci ? qr/^$value$/i : qr/^$value$/; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment