Skip to content

Commit

Permalink
fixed 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 102567b commit 946d2c2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 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 extraction bug in Mojo::DOM.
- Fixed small text and attribute extraction bug in Mojo::DOM.
- Fixed small inconsistency between routes and static dispatchers.

3.01 2012-07-01
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/DOM.pm
Expand Up @@ -64,7 +64,7 @@ sub attrs {
return $attrs unless @_;

# Get
return $attrs->{$_[0]} unless @_ > 1 || ref $_[0];
return $attrs->{$_[0]} // '' unless @_ > 1 || ref $_[0];

# Set
%$attrs = (%$attrs, %{ref $_[0] ? $_[0] : {@_}});
Expand Down
6 changes: 3 additions & 3 deletions t/mojo/dom.t
Expand Up @@ -438,9 +438,9 @@ is $dom->at('ook'), undef, 'no result';
is $dom->at('[xmlns\:bk]')->{'xmlns:bk'}, 'uri:book-ns', 'right attribute';
is $dom->at('[bk]')->{'xmlns:bk'}, 'uri:book-ns', 'right attribute';
is $dom->at('[bk]')->attrs('xmlns:bk'), 'uri:book-ns', 'right attribute';
is $dom->at('[bk]')->attrs('s:bk'), undef, 'no attribute';
is $dom->at('[bk]')->attrs('bk'), undef, 'no attribute';
is $dom->at('[bk]')->attrs('k'), undef, 'no attribute';
is $dom->at('[bk]')->attrs('s:bk'), '', 'no attribute';
is $dom->at('[bk]')->attrs('bk'), '', 'no attribute';
is $dom->at('[bk]')->attrs('k'), '', 'no attribute';
is $dom->at('[s\:bk]'), undef, 'no result';
is $dom->at('[k]'), undef, 'no result';

Expand Down

0 comments on commit 946d2c2

Please sign in to comment.