Subject: | replacing self-closing elements breaks event stream |
Date: | Wed, 3 Aug 2016 12:28:09 +0000 |
To: | "bug-HTML-Zoom [...] rt.cpan.org" <bug-HTML-Zoom [...] rt.cpan.org> |
From: | Lukas Mai <Mai [...] jochen-schweizer.de> |
Consider the following program:
#!perl
use strict;
use warnings;
use HTML::Zoom;
my $html = <<'_EOT_';
<html>
<body>
<form id="final">
<input type="checkbox" class="foo" />
<span>Hello!</span>
<textarea>51</textarea>
<input type="submit" />
</form>
</body>
</html>
_EOT_
HTML::Zoom->from_html($html)
->select('.foo')
# ->replace_content('')->then
->replace('')
->select('form#final')
->collect({ into => \my @body })
->run;
my $zoom2 = HTML::Zoom->from_html(<<'_EOT_');
<div id="inject">
</div>
_EOT_
print $zoom2
->select('#inject')
->replace_content(\@body)
->to_html;
__END__
The output I expected to get:
<div id="inject"><form id="final">
<span>Hello!</span>
<textarea>51</textarea>
<input type="submit" />
</form></div>
The output I actually get (using HTML::Zoom 0.009009):
<div id="inject"><form id="final">
</div>
Uncommenting the ->replace_content('') line fixes things, probably because it turns "<input ... />" into "<input ...></input>" internally.
--
Lukas Mai / Software Developer
Jochen Schweizer Technology Solutions GmbH
Rosenheimer Str. 145 e-f, 81671 München
HRB München 203111; Geschäftsführer: Florian Herschke, Prokurist: Saad Daoud