Skip to content

Commit

Permalink
fixed bug in Mojo::DOM::CSS where selected results would also include…
Browse files Browse the repository at this point in the history
… the current root element
  • Loading branch information
kraih committed Nov 24, 2014
1 parent 1ec8587 commit ab59ccd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Changes
@@ -1,6 +1,8 @@

5.65 2014-11-24
- Improved installable scripts to use #!perl. (jberger)
- Fixed bug in Mojo::DOM::CSS where selected results would also include the
current root element.

5.64 2014-11-22
- Fixed bug in Mojolicious::Commands where the global Getopt::Long
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/DOM/CSS.pm
Expand Up @@ -235,7 +235,7 @@ sub _select {
# Tag
if ($type eq 'tag') {
unshift @queue, @$current[4 .. $#$current];
next unless _match($pattern, $current, $tree);
next if $current eq $tree || !_match($pattern, $current, $tree);
$one ? return $current : push @results, $current;
}

Expand Down
4 changes: 4 additions & 0 deletions t/mojo/dom.t
Expand Up @@ -461,6 +461,10 @@ $dom->replace('A<div>B<p>C<b>D<i><u>E</u></i>F</b>G</p><div>H</div></div>I');
is $dom->find(':not(div):not(i):not(u)')->map('strip')->first->root,
'A<div>BCD<i><u>E</u></i>FG<div>H</div></div>I', 'right result';
is $dom->at('i')->to_string, '<i><u>E</u></i>', 'right result';
$dom = Mojo::DOM->new('<div><div>A</div><div>B</div>C</div>');
is $dom->at('div')->at('div')->text, 'A', 'right text';
$dom->at('div')->find('div')->map('strip');
is "$dom", '<div>ABC</div>', 'right result';

# Replace element content
$dom = Mojo::DOM->new->parse('<div>foo<p>lalala</p>bar</div>');
Expand Down

0 comments on commit ab59ccd

Please sign in to comment.