Skip to content

Commit

Permalink
fixed whitespace bug in Mojo::DOM::HTML (closes #467)
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 15, 2013
1 parent bc58398 commit 4d90541
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,6 +1,7 @@

3.91 2013-03-15
- Improved tests.
- Fixed whitespace bug in Mojo::DOM::HTML.

3.90 2013-03-14
- Added direct array access for parsed parameters to Mojo::Parameters.
Expand Down
1 change: 1 addition & 0 deletions lib/Mojo/DOM/HTML.pm
Expand Up @@ -42,6 +42,7 @@ my $TOKEN_RE = qr/
<(
\s*
[^>\s]+ # Tag
\s*
(?:$ATTR_RE)* # Attributes
)>
)??
Expand Down
7 changes: 7 additions & 0 deletions t/mojo/dom.t
Expand Up @@ -2135,6 +2135,13 @@ is $dom->find('div > ul li')->[2], undef, 'no result';
is $dom->find('div > ul ul')->[0]->text, 'C', 'right text';
is $dom->find('div > ul ul')->[1], undef, 'no result';

# Extra whitespace
$dom = Mojo::DOM->new('< span>a< /span><b >b</b><span >c</ span>');
is $dom->at('span')->text, 'a', 'right text';
is $dom->at('span + b')->text, 'b', 'right text';
is $dom->at('b + span')->text, 'c', 'right text';
is "$dom", '<span>a</span><b>b</b><span>c</span>', 'right result';

# Bad charset
$dom = Mojo::DOM->new->charset('doesnotexist');
$dom->parse(qq{<html><div id="a">A</div></html>});
Expand Down

0 comments on commit 4d90541

Please sign in to comment.