Subject: | close tag missing from optionally empty XML tags |
When you add a tag to empty_element_map and it optionally contains text
or other content, when the content is present the opening tag correctly
has '<foo>' instead of '<foo/>', however the closing tag is missing from
the text returned by as_XML.
This is due to traverse not correctly validating tags as empty in the
check for setting callbacks.
Attached is a patch which fixes this bug.
Cheers, Jeff.
Subject: | missing_close_tag.patch |
diff -ur HTML-Tree-3.23/lib/HTML/Element.pm HTML-Tree-3.23-fix/lib/HTML/Element.pm
--- HTML-Tree-3.23/lib/HTML/Element.pm 2006-11-13 03:13:33.000000000 +1000
+++ HTML-Tree-3.23-fix/lib/HTML/Element.pm 2009-09-23 14:22:12.000000000 +1000
@@ -2041,7 +2041,7 @@
and ref($this) # sanity
and not(
$this->{'_empty_element'}
- || $empty_element_map->{$this->{'_tag'} || ''}
+ || ($empty_element_map->{$this->{'_tag'} || ''} && !@{$this->{'_content'}})
) # things that don't get post-order callbacks
) {
shift @I;