Skip to content

Commit

Permalink
fixed another small attribute extraction bug in Mojo::DOM
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 3, 2012
1 parent 946d2c2 commit 54c62bf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Changes
Expand Up @@ -6,7 +6,7 @@
- Improved documentation.
- Improved tests.
- Fixed JSON Pointer escaping.
- Fixed small text and attribute extraction bug in Mojo::DOM.
- Fixed small text and attribute extraction bugs in Mojo::DOM.
- Fixed small inconsistency between routes and static dispatchers.

3.01 2012-07-01
Expand Down
6 changes: 2 additions & 4 deletions lib/Mojo/DOM.pm
Expand Up @@ -56,11 +56,9 @@ sub at { shift->find(@_)->[0] }
sub attrs {
my $self = shift;

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

# Hash
my $attrs = $tree->[2];
my $tree = $self->tree;
my $attrs = $tree->[0] eq 'root' ? {} : $tree->[2];
return $attrs unless @_;

# Get
Expand Down
4 changes: 3 additions & 1 deletion t/mojo/dom.t
Expand Up @@ -2,7 +2,7 @@ use Mojo::Base -strict;

use utf8;

use Test::More tests => 774;
use Test::More tests => 776;

# "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 @@ -133,6 +133,8 @@ is $dom->namespace, '', 'no namespace';
is $dom->type, '', 'no type';
is $dom->text_before, '', 'no text';
is $dom->text_after, '', 'no text';
is $dom->attrs('foo'), '', 'no attribute';
is $dom->attrs(foo => 'bar')->attrs('foo'), '', 'no attribute';

# Class and ID
$dom = Mojo::DOM->new->parse('<div id="id" class="class">a</div>');
Expand Down

0 comments on commit 54c62bf

Please sign in to comment.