Navigation Menu

Skip to content

Commit

Permalink
fixed a few "0" value bugs in Mojo::DOM::HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Nov 17, 2013
1 parent 7842d0a commit 0de0c92
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,9 +1,10 @@

4.58 2013-11-16
4.58 2013-11-17
- Improved IIS and WebSphere compatibility of Mojo::Message::Request.
- Improved Mojo::DOM::HTML performance.
- Fixed recursion bug in Mojo::Reactor::EV where timers could run more than
once.
- Fixed a few "0" value bugs in Mojo::DOM::HTML.

4.57 2013-11-11
- Improved compatibility with IO::Socket::SSL 1.957.
Expand Down
8 changes: 4 additions & 4 deletions lib/Mojo/DOM/HTML.pm
Expand Up @@ -99,16 +99,16 @@ sub parse {
push @$current, ['text', html_unescape $text] if length $text;

# DOCTYPE
if ($doctype) { push @$current, ['doctype', $doctype] }
if (defined $doctype) { push @$current, ['doctype', $doctype] }

# Comment
elsif ($comment) { push @$current, ['comment', $comment] }
elsif (defined $comment) { push @$current, ['comment', $comment] }

# CDATA
elsif ($cdata) { push @$current, ['cdata', $cdata] }
elsif (defined $cdata) { push @$current, ['cdata', $cdata] }

# Processing instruction (try to detect XML)
elsif ($pi) {
elsif (defined $pi) {
$self->xml(1) if !defined $self->xml && $pi =~ /xml/i;
push @$current, ['pi', $pi];
}
Expand Down
4 changes: 4 additions & 0 deletions t/mojo/dom.t
Expand Up @@ -2206,6 +2206,10 @@ $dom = Mojo::DOM->new('0');
is "$dom", '0', 'right result';
$dom->append_content('');
is "$dom", '0☃', 'right result';
is $dom->parse('<!DOCTYPE 0>'), '<!DOCTYPE 0>', 'successful roundtrip';
is $dom->parse('<!--0-->'), '<!--0-->', 'successful roundtrip';
is $dom->parse('<![CDATA[0]]>'), '<![CDATA[0]]>', 'successful roundtrip';
is $dom->parse('<?0?>'), '<?0?>', 'successful roundtrip';

# Comments
$dom = Mojo::DOM->new(<<EOF);
Expand Down

0 comments on commit 0de0c92

Please sign in to comment.