our $VERSION = '0.001';
+sub new {
+ my $class = shift;
+ my $self = bless \DOM::Tiny::HTML->new, ref $class || $class;
+ return @_ ? $self->parse(@_) : $self;
+}
+
sub all_text { shift->_all_text(1, @_) }
sub ancestors { _select($_[0]->_collect($_[0]->_ancestors), $_[1]) }
return undef;
}
-sub new {
- my $class = shift;
- my $self = bless \DOM::Tiny::HTML->new, ref $class || $class;
- return @_ ? $self->parse(@_) : $self;
-}
-
sub next { $_[0]->_maybe($_[0]->_siblings(1, 0)->[1]) }
sub next_node { $_[0]->_maybe($_[0]->_siblings(0, 0)->[1]) }
sub _parse { DOM::Tiny::HTML->new(xml => shift->xml)->parse(shift)->tree }
sub _replace {
- my ($self, $parent, $tree, @nodes) = @_;
- splice @$parent, _offset($parent, $tree), 1, _link($parent, @nodes);
+ my ($self, $parent, $child, @nodes) = @_;
+ splice @$parent, _offset($parent, $child), 1, _link($parent, @nodes);
return $self->parent;
}
L<DOM::Tiny> implements the following methods.
+=head2 new
+
+ my $dom = DOM::Tiny->new;
+ my $dom = DOM::Tiny->new('<foo bar="baz">I ♥ DOM::Tiny!</foo>');
+
+Construct a new scalar-based L<DOM::Tiny> object and L</"parse"> HTML/XML
+fragment if necessary.
+
=head2 all_text
my $trimmed = $dom->all_text;
# Find namespace for an element that may or may not have a namespace prefix
my $namespace = $dom->at('svg > circle')->namespace;
-=head2 new
-
- my $dom = DOM::Tiny->new;
- my $dom = DOM::Tiny->new('<foo bar="baz">I ♥ DOM::Tiny!</foo>');
-
-Construct a new scalar-based L<DOM::Tiny> object and L</"parse"> HTML/XML
-fragment if necessary.
-
=head2 next
my $sibling = $dom->next;
$dom = $dom->tap(sub {...});
-Alias for L<Mojo::Base/"tap">.
+Equivalent to L<Mojo::Base/"tap">.
=head2 text