X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FHTML%2FZoom%2FSelectorParser.pm;h=be081756f17d1bf1da1190e6940ca99af7924917;hb=5b63d2447b01acd333b2a0a9adb7aa793b72fcf6;hp=d3a505abb6b4d4e58be60255e56c75270075fd39;hpb=6818876e0628aa9f0abd811f35bcd8ec3b912a78;p=catagits%2FHTML-Zoom.git diff --git a/lib/HTML/Zoom/SelectorParser.pm b/lib/HTML/Zoom/SelectorParser.pm index d3a505a..be08175 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,14 +103,19 @@ sub _raw_parse_simple_selector { } }; - # '[attr] - match attribute being present: + # '[attr]' - match attribute being present: /\G\[$sel_re\]/gc and return do { my $attribute = $1; sub { exists $_[0]->{attrs}{$attribute}; } - } + }; + + # none of the above matched, try catching some obvious errors: + + # indicate unmatched square bracket: + /\G\[[^\]]*/gc and $_[0]->_blam('Unmatched ['); } }