Skip to content

Commit

Permalink
changed Mojo::DOM objects to be scalar-based instead of array
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 13, 2014
1 parent 6264819 commit d1f31b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,5 +1,5 @@

4.80 2014-02-12
4.80 2014-02-13
- Merged Mojo::DOM::Node into Mojo::DOM.
- Added next_sibling and previous_sibling methods to Mojo::DOM.
- Added last method to Mojo::Collection.
Expand Down
10 changes: 5 additions & 5 deletions lib/Mojo/DOM.pm
Expand Up @@ -120,7 +120,7 @@ sub namespace {

sub new {
my $class = shift;
my $self = bless [Mojo::DOM::HTML->new], ref $class || $class;
my $self = bless \Mojo::DOM::HTML->new, ref $class || $class;
return @_ ? $self->parse(@_) : $self;
}

Expand Down Expand Up @@ -213,7 +213,7 @@ sub text_before {
return _text(\@nodes, 0, _trim($tree->[3], $trim));
}

sub to_string { shift->[0]->render }
sub to_string { shift->_delegate('render') }

# DEPRECATED in Top Hat!
sub to_xml {
Expand Down Expand Up @@ -296,8 +296,8 @@ sub _css { Mojo::DOM::CSS->new(tree => shift->tree) }

sub _delegate {
my ($self, $method) = (shift, shift);
return $self->[0]->$method unless @_;
$self->[0]->$method(@_);
return $$self->$method unless @_;
$$self->$method(@_);
return $self;
}

Expand Down Expand Up @@ -684,7 +684,7 @@ Find this element's namespace.
my $dom = Mojo::DOM->new;
my $dom = Mojo::DOM->new('<foo bar="baz">I ♥ Mojolicious!</foo>');
Construct a new array-based L<Mojo::DOM> object and L</"parse"> HTML/XML
Construct a new scalar-based L<Mojo::DOM> object and L</"parse"> HTML/XML
fragment if necessary.
=head2 next
Expand Down

0 comments on commit d1f31b8

Please sign in to comment.