From: Arthur Axel 'fREW' Schmidt Date: Mon, 12 Apr 2010 05:36:59 +0000 (-0500) Subject: E[attr~="foo"] X-Git-Tag: release_0.009004~60 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FHTML-Zoom.git;a=commitdiff_plain;h=04d71924c4a8c70294b48e682a3b581899cedfb4 E[attr~="foo"] --- diff --git a/lib/HTML/Zoom/SelectorParser.pm b/lib/HTML/Zoom/SelectorParser.pm index 029f688..096eb3e 100644 --- a/lib/HTML/Zoom/SelectorParser.pm +++ b/lib/HTML/Zoom/SelectorParser.pm @@ -18,6 +18,25 @@ sub _raw_parse_simple_selector { /\G\*/gc and return sub { 1 }; + # 'el[attr~="foo"] + + /\G$sel_re\[$sel_re~="$sel_re"\]/gc and + return do { + my $name = $1; + my $attr = $2; + my $val = $3; + sub { + if ( + $_[0]->{name} && $_[0]->{name} eq $name and + $_[0]->{attrs}{$attr} + ) { + my %vals = map { $_ => 1 } split /\s+/, $_[0]->{attrs}{$attr}; + return $vals{$val} + } + return undef + } + }; + # 'el[attr="foo"] /\G$sel_re\[$sel_re="$sel_re"\]/gc and