E[attr="foo"]
Arthur Axel 'fREW' Schmidt [Sun, 11 Apr 2010 07:54:34 +0000 (02:54 -0500)]
lib/HTML/Zoom/SelectorParser.pm

index c485da4..029f688 100644 (file)
@@ -18,6 +18,19 @@ 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 {
+           $_[0]->{name} && $_[0]->{name} eq $name and
+           $_[0]->{attrs}{$attr} && $_[0]->{attrs}{$attr} eq $val
+        }
+      };
+
     # 'element' - match on tag name
 
     /\G$sel_re/gc and