X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDOM%2FTiny%2FCSS.pm;h=a6941861a0af9853ebef6872a49a37ec2ae1ff54;hb=927f135111d601e084c5a50e2d806bddd5c9cefb;hp=dbe552a48eceaa04268cc8045fe6783b477e7336;hpb=d6512b506041e5f51cb53585efc6823ec5f3b109;p=catagits%2FDOM-Tiny.git diff --git a/lib/DOM/Tiny/CSS.pm b/lib/DOM/Tiny/CSS.pm index dbe552a..a694186 100644 --- a/lib/DOM/Tiny/CSS.pm +++ b/lib/DOM/Tiny/CSS.pm @@ -98,7 +98,9 @@ sub _compile { # Attributes elsif ($css =~ /\G$ATTR_RE/gco) { - push @$last, ['attr', _name($1), _value($2 // '', $3 // $4 // $5, $6)]; + my $op = defined $2 ? $2 : ''; + my $value = defined $3 ? $3 : (defined $4 ? $4 : $5); + push @$last, ['attr', _name($1), _value($op, $value, $6)]; } # Pseudo-class (":not" contains more selectors) @@ -133,7 +135,7 @@ sub _equation { return $num if $equation !~ /(?:(-?(?:\d+)?)?(n))?\s*\+?\s*(-?\s*\d+)?\s*$/i; $num->[0] = defined($1) && $1 ne '' ? $1 : $2 ? 1 : 0; $num->[0] = -1 if $num->[0] eq '-'; - $num->[1] = $3 // 0; + $num->[1] = $3 || 0; $num->[1] =~ s/\s+//g; return $num; }