-
-
Save anonymous/eb4ca47836d1a26e7f2c 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.pm b/lib/Mojo/DOM.pm | |
index 2bda8b1..86ee7f1 100644 | |
--- a/lib/Mojo/DOM.pm | |
+++ b/lib/Mojo/DOM.pm | |
@@ -15,6 +15,7 @@ use Mojo::DOM::CSS; | |
use Mojo::DOM::HTML; | |
use Mojo::Util 'squish'; | |
use Scalar::Util qw(blessed weaken); | |
+use Storable 'dclone'; | |
sub all_text { shift->_all_text(1, @_) } | |
@@ -280,7 +281,11 @@ sub _offset { | |
sub _parent { $_[0]->tree->[$_[0]->type eq 'tag' ? 3 : 2] } | |
-sub _parse { Mojo::DOM::HTML->new(xml => shift->xml)->parse(shift)->tree } | |
+sub _parse { | |
+ my ($self, $html) = @_; | |
+ return dclone $html->tree if blessed $html && $html->isa('Mojo::DOM'); | |
+ return Mojo::DOM::HTML->new(xml => $self->xml)->parse($html)->tree; | |
+} | |
sub _replace { | |
my ($self, $parent, $tree, $new) = @_; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment