Skip to content

Commit

Permalink
reuse a little more code in Mojo::DOM
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 29, 2013
1 parent 5c37fa9 commit 3bfbf40
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lib/Mojo/DOM.pm
Expand Up @@ -36,10 +36,7 @@ sub new {
return @_ ? $self->parse(@_) : $self;
}

sub all_text {
my $tree = shift->tree;
return _text(_elements($tree), 1, _trim($tree, @_));
}
sub all_text { shift->_content(1, @_) }

sub append { shift->_add(1, @_) }

Expand Down Expand Up @@ -182,10 +179,7 @@ sub strip {
return $self->_replace($tree, ['root', @{_elements($tree)}]);
}

sub text {
my $tree = shift->tree;
return _text(_elements($tree), 0, _trim($tree, @_));
}
sub text { shift->_content(0, @_) }

sub text_after {
my ($self, $trim) = @_;
Expand Down Expand Up @@ -244,6 +238,11 @@ sub _add {
return $self;
}

sub _content {
my $tree = shift->tree;
return _text(_elements($tree), shift, _trim($tree, @_));
}

sub _elements {
return [] unless my $e = shift;
return [@$e[_offset($e) .. $#$e]];
Expand Down

0 comments on commit 3bfbf40

Please sign in to comment.