Subject: | HTML::Element - self-closing tags like img don't self close |
In HTML-Element-3.16, tags like "img" that are meant to close themselves in XHTML: <img src="foo.png" />. HTML::Element doesn't seem to be keen on XHTML, so it doesn't do it, but it's playing merry hell with me modifying a valid XHTML document and spitting it out again.
I've attached a test case.
use strict;
BEGIN{
use vars qw( $tests );
use HTML::Element;
$tests = scalar keys %{ HTML::Element->_empty_element_map };
}
use Test::More tests => $tests + 1;
for ( keys %HTML::Tagset::emptyElement ) {
my $elem = HTML::Element->new( $_ );
my $expected = qq(<$_ />\n);
if ( $_ eq "~pi" ) {
$expected = "<?>\n";
} elsif ( $_ eq "~comment" ) {
$expected = "<!---->\n";
} elsif ( $_ eq "~literal" ) {
$expected = "\n";
} elsif ( $_ eq "~declaration" ) {
$expected = "<!>\n";
}
is ( $elem->as_HTML, $expected );
}
my $elem = HTML::Element->new( 'span' );
my $expected = "<span></span>\n";
is ( $elem->as_HTML, $expected );