Skip to content

Commit

Permalink
added a few more Mojo::DOM tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed May 30, 2011
1 parent a6fe287 commit c9a7c7f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Mojo/DOM.pm
Expand Up @@ -196,7 +196,7 @@ sub attrs {

# Not a tag
my $tree = $self->tree;
return if $tree->[0] eq 'root';
return {} if $tree->[0] eq 'root';

# Hash
my $attrs = $tree->[2];
Expand Down
6 changes: 5 additions & 1 deletion t/mojo/dom.t
Expand Up @@ -5,7 +5,7 @@ use warnings;

use utf8;

use Test::More tests => 583;
use Test::More tests => 587;

# "Homer gave me a kidney: it wasn't his, I didn't need it,
# and it came postage due- but I appreciated the gesture!"
Expand Down Expand Up @@ -1732,6 +1732,8 @@ $dom->a->B->c->each(sub { push @results, $_->text });
is_deeply \@results, [qw/bar baz/], 'right results';
is $dom->a->B->c, qq/<c id="three">bar<\/c>\n<c ID="four">baz<\/c>/,
'right result';
is_deeply [keys %$dom], [], 'root has no attributes';
is $dom->find('#nothing'), '', 'no result';

# Direct hash access to attributes in HTML mode
$dom = Mojo::DOM->new(<<EOF);
Expand Down Expand Up @@ -1765,3 +1767,5 @@ $dom->a->b->c->each(sub { push @results, $_->text });
is_deeply \@results, [qw/bar baz/], 'right results';
is $dom->a->b->c, qq/<c id="three">bar<\/c>\n<c id="four">baz<\/c>/,
'right result';
is_deeply [keys %$dom], [], 'root has no attributes';
is $dom->find('#nothing'), '', 'no result';

0 comments on commit c9a7c7f

Please sign in to comment.