-
-
Save anonymous/b1ec23ba686eb9cb31a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Mojo/DOM/HTML.pm b/lib/Mojo/DOM/HTML.pm | |
index 97e1d25..59d5a29 100644 | |
--- a/lib/Mojo/DOM/HTML.pm | |
+++ b/lib/Mojo/DOM/HTML.pm | |
@@ -3,6 +3,7 @@ use Mojo::Base -base; | |
use Mojo::Util qw(html_unescape xml_escape); | |
use Scalar::Util 'weaken'; | |
+use Storable 'dclone'; | |
has tree => sub { ['root'] }; | |
has 'xml'; | |
@@ -101,7 +102,10 @@ my %BLOCK = map { $_ => 1 } ( | |
); | |
sub parse { | |
- my ($self, $html) = (shift, "$_[0]"); | |
+ my ($self, $html) = @_; | |
+ | |
+ return $self->tree(dclone $html->tree)->xml($html->xml) | |
+ if ref $html && $html->isa('Mojo::DOM'); | |
my $xml = $self->xml; | |
my $current = my $tree = ['root']; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment