Skip to content

Commit

Permalink
fixed whitespace bug in Mojo::DOM::HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Dec 6, 2014
1 parent 643865a commit 7b379d4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -4,6 +4,7 @@
- Removed deprecated render_static method from Mojolicious::Controller.
- Improved Mojo::DOM::HTML performance slightly.
- Fixed parent combinator bug in Mojo::DOM::CSS.
- Fixed whitespace bug in Mojo::DOM::HTML.

5.68 2014-12-02
- Improved Mojo::DOM::CSS performance significantly.
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/DOM/HTML.pm
Expand Up @@ -117,10 +117,10 @@ sub parse {
if (defined $tag) {

# End
if ($tag =~ /^\/\s*(.+)/) { _end($xml ? $1 : lc $1, $xml, \$current) }
if ($tag =~ /^\/\s*(\S+)/) { _end($xml ? $1 : lc $1, $xml, \$current) }

# Start
elsif ($tag =~ m!([^\s/]+)([\s\S]*)!) {
elsif ($tag =~ m!^([^\s/]+)([\s\S]*)!) {
my ($start, $attr) = ($xml ? $1 : lc $1, $2);

# Attributes
Expand Down
4 changes: 2 additions & 2 deletions t/mojo/dom.t
Expand Up @@ -2320,9 +2320,9 @@ is $dom->parse('<![CDATA[0]]>'), '<![CDATA[0]]>', 'successful roundtrip';
is $dom->parse('<?0?>'), '<?0?>', 'successful roundtrip';

# Not self-closing
$dom = Mojo::DOM->new('<div /><div><pre />test</div>');
$dom = Mojo::DOM->new('<div />< div ><pre />test</div >123');
is $dom->at('div > div > pre')->text, 'test', 'right text';
is "$dom", '<div><div><pre>test</pre></div></div>', 'right result';
is "$dom", '<div><div><pre>test</pre></div>123</div>', 'right result';
$dom = Mojo::DOM->new('<p /><svg><circle /><circle /></svg>');
is $dom->find('p > svg > circle')->size, 2, 'two circles';
is "$dom", '<p><svg><circle></circle><circle></circle></svg></p>',
Expand Down

0 comments on commit 7b379d4

Please sign in to comment.