Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
just check if we have a parent
  • Loading branch information
kraih committed Jan 27, 2015
1 parent d10b02b commit 7f13383
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions lib/Mojo/DOM.pm
Expand Up @@ -203,10 +203,8 @@ sub _all_text {
sub _ancestors {
my ($self, $root) = @_;

return if $self->node eq 'root';

return unless my $tree = $self->_parent;
my @ancestors;
my $tree = $self->_parent;
do { push @ancestors, $tree }
while ($tree->[0] eq 'tag') && ($tree = $tree->[3]);
return $root ? $ancestors[-1] : @ancestors[0 .. $#ancestors - 1];
Expand Down

0 comments on commit 7f13383

Please sign in to comment.