X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FHTML%2FZoom%2FSelectorParser.pm;h=ef61d93e349449a692fefebaa395c870cd7817f6;hb=24725e7b32b680b376c06b1f9d641ec11fc1d067;hp=9bc7bc39439fda25dacf927e3be86cb3277bf067;hpb=bd4e2ca023a71bbc87d89bb52e7ad7e9b417a98d;p=catagits%2FHTML-Zoom.git diff --git a/lib/HTML/Zoom/SelectorParser.pm b/lib/HTML/Zoom/SelectorParser.pm index 9bc7bc3..ef61d93 100644 --- a/lib/HTML/Zoom/SelectorParser.pm +++ b/lib/HTML/Zoom/SelectorParser.pm @@ -81,6 +81,17 @@ sub _raw_parse_simple_selector { } }; + # '[attr~=bar]' - match attribute contains word + /\G\[$sel_re~=$match_value_re\]/gc and + return do { + my $attribute = $1; + my $value = $2; + sub { + $_[0]->{attrs}{$attribute} + && grep { $_ eq $value } split(' ', $_[0]->{attrs}{$attribute}); + } + }; + # '[attr=bar]' - match attributes /\G\[$sel_re=$match_value_re\]/gc and return do { @@ -92,7 +103,18 @@ sub _raw_parse_simple_selector { } }; - # '[attr] - match attribute being present: + # '[attr!=bar]' - attributes doesn't match + /\G\[$sel_re!=$match_value_re\]/gc and + return do { + my $attribute = $1; + my $value = $2; + sub { + ! ($_[0]->{attrs}{$attribute} + && $_[0]->{attrs}{$attribute} eq $value); + } + }; + + # '[attr]' - match attribute being present: /\G\[$sel_re\]/gc and return do { my $attribute = $1;