Subject: | textarea broken by $root->as_HTML( .., ' ' ) indentation. |
Hi.
I used CSS::Inliner.
CSS::Inliner depend HTML::Tree.
I occurred <textarea> broken.
I found a bug and fixed and wrote test bit.
Please merge this patch.
Cheers
Tomohiro Hosaka
Subject: | bug_textarea.txt |
diff -ru HTML-Tree-4.2.orig/lib/HTML/Element.pm HTML-Tree-4.2/lib/HTML/Element.pm
--- HTML-Tree-4.2.orig/lib/HTML/Element.pm 2011-04-06 17:37:54.000000000 +0900
+++ HTML-Tree-4.2/lib/HTML/Element.pm 2011-08-21 06:31:36.000000000 +0900
@@ -1583,7 +1583,7 @@
$last_tag_tightenable = $this_tag_tightenable;
++$nonindentable_ancestors
- if $tag eq 'pre'
+ if $tag eq 'pre' or $tag eq 'textarea'
or $HTML::Tagset::isCDATA_Parent{$tag};
}
@@ -1594,7 +1594,7 @@
{
# on the way out
- if ( $tag eq 'pre'
+ if ( $tag eq 'pre' or $tag eq 'textarea'
or $HTML::Tagset::isCDATA_Parent{$tag} )
{
--$nonindentable_ancestors;
diff -ru HTML-Tree-4.2.orig/t/body.t HTML-Tree-4.2/t/body.t
--- HTML-Tree-4.2.orig/t/body.t 2011-04-06 17:37:54.000000000 +0900
+++ HTML-Tree-4.2/t/body.t 2011-08-21 06:30:34.000000000 +0900
@@ -3,7 +3,7 @@
use warnings;
use strict;
-use Test::More tests => 11;
+use Test::More tests => 13;
BEGIN {
use_ok('HTML::TreeBuilder');
@@ -89,3 +89,12 @@
"<html><head></head><body><b>\$self->escape</b></body></html>" )
; # 3.22 compatability
}
+
+NO_INDENT_PRE_AND_TEXTAREA: {
+ my $root = HTML::TreeBuilder->new();
+ my $pre = '<pre></pre>';
+ my $textarea = '<textarea></textarea>';
+ my $html = $root->parse_content("<html><head></head><body>$pre$textarea</body></html>");
+ like( $html->as_HTML(), qr/$pre.*$textarea/ );
+ like( $html->as_HTML( undef, " " ), qr/$pre.*$textarea/ );
+}