Subject: | Misplaced unknown element when calling as_HTML |
Date: | Mon, 30 Mar 2015 16:01:55 +0200 |
To: | bug-HTML-Tree [...] rt.cpan.org |
From: | Marco Pessotto <melmothx [...] gmail.com> |
Hi!
It looks like unknown elements in the root are misplaced when calling
as_HTML:
#!perl
use strict;
use warnings;
use Test::More tests => 2;
use HTML::TreeBuilder;
my $tree = HTML::TreeBuilder->new;
$tree->ignore_unknown(0); # otherwise nav is cut out
my $html =<<'HTML';
<nav class="navbar navbar-default">
<div class="container-fluid">Test</div>
</nav>
HTML
$tree->parse($html); $tree->eof;
like $tree->as_HTML, qr{<nav.*</div>\s*</nav>}s, "<nav> at the root";
like $tree->as_HTML, qr{</nav>\s*</body>\s*</html>}s, "<nav> at the root";
## output
1..2
not ok 1 - <nav> at the root
# Failed test '<nav> at the root'
# at t/html/treebuilder-nav.t line 17.
# '<html><head></head><body><div class="container-fluid">Test</div> </body><nav class="navbar navbar-default"> </nav></html>'
# doesn't match '(?^s:<nav.*</div>\s*</nav>)'
not ok 2 - <nav> at the root
# Failed test '<nav> at the root'
# at t/html/treebuilder-nav.t line 18.
# '<html><head></head><body><div class="container-fluid">Test</div> </body><nav class="navbar navbar-default"> </nav></html>'
# doesn't match '(?^s:</nav>\s*</body>\s*</html>)'
# Looks like you failed 2 tests of 2.
Best wishes
--
Marco