Skip to content

Commit

Permalink
fixed unquoted attribute selector bug in Mojo::DOM::CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 6, 2013
1 parent 003e48e commit 37ad0e0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,5 +1,6 @@

4.45 2013-10-05
4.45 2013-10-06
- Fixed unquoted attribute selector bug in Mojo::DOM::CSS.

4.44 2013-10-04
- Removed experimental status from label_for helper.
Expand Down
6 changes: 3 additions & 3 deletions lib/Mojo/DOM/CSS.pm
Expand Up @@ -6,11 +6,11 @@ has 'tree';
my $ESCAPE_RE = qr/\\[^0-9a-fA-F]|\\[0-9a-fA-F]{1,6}/;
my $ATTR_RE = qr/
\[
((?:$ESCAPE_RE|[\w\-])+) # Key
((?:$ESCAPE_RE|[\w\-])+) # Key
(?:
(\W)? # Operator
(\W)? # Operator
=
(?:"((?:\\"|[^"])*)"|(\S+)) # Value
(?:"((?:\\"|[^"])*)"|([^\]]+)) # Value
)?
\]
/x;
Expand Down
16 changes: 8 additions & 8 deletions t/mojo/dom.t
Expand Up @@ -126,11 +126,11 @@ $simple->parent->attr(bar => 'baz')->attr({this => 'works', too => 'yea'});
is $simple->parent->attr('bar'), 'baz', 'right parent attribute';
is $simple->parent->attr('this'), 'works', 'right parent attribute';
is $simple->parent->attr('too'), 'yea', 'right parent attribute';
is $dom->at('test#test')->type, 'test', 'right type';
is $dom->at('[class$="ing"]')->type, 'simple', 'right type';
is $dom->at('[class="working"]')->type, 'simple', 'right type';
is $dom->at('[class$=ing]')->type, 'simple', 'right type';
is $dom->at('[class=working]')->type, 'simple', 'right type';
is $dom->at('test#test')->type, 'test', 'right type';
is $dom->at('[class$="ing"]')->type, 'simple', 'right type';
is $dom->at('[class="working"]')->type, 'simple', 'right type';
is $dom->at('[class$=ing]')->type, 'simple', 'right type';
is $dom->at('[class=working][class]')->type, 'simple', 'right type';
is $dom->at('foo > simple')->next->type, 'test', 'right type';
is $dom->at('foo > simple')->next->next->type, 'a', 'right type';
is $dom->at('foo > test')->previous->type, 'simple', 'right type';
Expand Down Expand Up @@ -203,9 +203,9 @@ is $dom->at('script')->text, "alert('lalala');", 'right script content';
# HTML5 (unquoted values)
$dom
= Mojo::DOM->new->parse('<div id = test foo ="bar" class=tset>works</div>');
is $dom->at('#test')->text, 'works', 'right text';
is $dom->at('div')->text, 'works', 'right text';
is $dom->at('[foo="bar"]')->text, 'works', 'right text';
is $dom->at('#test')->text, 'works', 'right text';
is $dom->at('div')->text, 'works', 'right text';
is $dom->at('[foo=bar][foo="bar"]')->text, 'works', 'right text';
is $dom->at('[foo="ba"]'), undef, 'no result';
is $dom->at('[foo=bar]')->text, 'works', 'right text';
is $dom->at('[foo=ba]'), undef, 'no result';
Expand Down

0 comments on commit 37ad0e0

Please sign in to comment.