From: Arthur Axel 'fREW' Schmidt Date: Thu, 27 May 2010 15:25:40 +0000 (-0500) Subject: Make more tests pass X-Git-Tag: release_0.009004~54 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FHTML-Zoom.git;a=commitdiff_plain;h=de4457aae9433f7f960ac2205f4805fef3474c91 Make more tests pass --- diff --git a/lib/HTML/Zoom/SelectorParser.pm b/lib/HTML/Zoom/SelectorParser.pm index 6acc029..9f72b0a 100644 --- a/lib/HTML/Zoom/SelectorParser.pm +++ b/lib/HTML/Zoom/SelectorParser.pm @@ -14,8 +14,8 @@ my $match_attr_on_regex = sub { my ($self, $name, $attr, $regex) = @_; sub { - $self->{name} && $self->{name} eq $name and - $self->{attrs}{$attr} && $self->{attrs}{$attr} =~ $regex + $_[0]->{name} && $_[0]->{name} eq $name and + $_[0]->{attrs}{$attr} && $_[0]->{attrs}{$attr} =~ $regex } }; @@ -23,8 +23,8 @@ my $match_attr_on_eq = sub { my ($self, $name, $attr, $val) = @_; sub { - $self->{name} && $self->{name} eq $name and - $self->{attrs}{$attr} && $self->{attrs}{$attr} eq $val + $_[0]->{name} && $_[0]->{name} eq $name and + $_[0]->{attrs}{$attr} && $_[0]->{attrs}{$attr} eq $val } }; @@ -86,6 +86,15 @@ sub _raw_parse_simple_selector { } }; + # 'el.class1' - element + class + + /\G$sel_re\.$sel_re/gc and + return do { $_[0]->$match_attr_on_eq($1, 'class', $2) }; + + # 'el#id' - element + id + /\G$sel_re#$sel_re/gc and + return do { $_[0]->$match_attr_on_eq($1, 'id', $2) }; + # 'element' - match on tag name /\G$sel_re/gc and @@ -114,16 +123,6 @@ sub _raw_parse_simple_selector { } }; - # 'el.class1' - element + class - - /\G$sel_re\.$sel_re/gc and - return do { $_[0]->$match_attr_on_eq($1, 'class', $3) }; - - # 'el#id' - element + id - - /\G$sel_re#$sel_re/gc and - return do { $_[0]->$match_attr_on_eq($1, 'id', $3) }; - confess "Couldn't parse $_ as starting with simple selector"; } }