From: Arthur Axel 'fREW' Schmidt Date: Mon, 12 Apr 2010 05:42:35 +0000 (-0500) Subject: E[attr] and E[attr^="foo"] X-Git-Tag: release_0.009004~59 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FHTML-Zoom.git;a=commitdiff_plain;h=676159cb98a5044d3f108d51f2b6eaaee20f4ae8 E[attr] and E[attr^="foo"] --- diff --git a/lib/HTML/Zoom/SelectorParser.pm b/lib/HTML/Zoom/SelectorParser.pm index 096eb3e..3395940 100644 --- a/lib/HTML/Zoom/SelectorParser.pm +++ b/lib/HTML/Zoom/SelectorParser.pm @@ -37,6 +37,19 @@ sub _raw_parse_simple_selector { } }; + # 'el[attr^="foo"] + + /\G$sel_re\[$sel_re\^="$sel_re"\]/gc and + return do { + my $name = $1; + my $attr = $2; + my $val = $3; + sub { + $_[0]->{name} && $_[0]->{name} eq $name and + $_[0]->{attrs}{$attr} && $_[0]->{attrs}{$attr} =~ /^\Q$val\E/ + } + }; + # 'el[attr="foo"] /\G$sel_re\[$sel_re="$sel_re"\]/gc and @@ -50,6 +63,17 @@ sub _raw_parse_simple_selector { } }; + # 'el[attr] + + /\G$sel_re\[$sel_re\]/gc and + return do { + my $name = $1; + my $attr = $2; + sub { + $_[0]->{name} && $_[0]->{name} eq $name && $_[0]->{attrs}{$attr} + } + }; + # 'element' - match on tag name /\G$sel_re/gc and