Skip to content

Commit

Permalink
mention which Mojo::DOM methods return new Mojo::DOM objects (closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 19, 2013
1 parent c144524 commit 3318bcb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
7 changes: 7 additions & 0 deletions lib/Mojo/Collection.pm
Expand Up @@ -231,6 +231,13 @@ from the results.
Create a new collection without duplicate elements.
=head1 ELEMENTS
Direct array reference access to elements is also possible.
say $collection->[23];
say for @$collection;
=head1 SEE ALSO
L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicio.us>.
Expand Down
25 changes: 13 additions & 12 deletions lib/Mojo/DOM.pm
Expand Up @@ -489,8 +489,8 @@ Append to element content.
my $result = $dom->at('html title');
Find a single element with CSS selectors. All selectors from L<Mojo::DOM::CSS>
are supported.
Find a single element with CSS selectors and return it as a L<Mojo::DOM>
object. All selectors from L<Mojo::DOM::CSS> are supported.
# Find first element with "svg" namespace definition
my $namespace = $dom->at('[xmlns\:svg]')->{'xmlns:svg'};
Expand All @@ -516,8 +516,8 @@ Charset used for decoding and encoding HTML/XML.
my $collection = $dom->children;
my $collection = $dom->children('div');
Return a L<Mojo::Collection> object containing the children of this element,
similar to C<find>.
Return a L<Mojo::Collection> object containing the children of this element as
L<Mojo::DOM> objects, similar to C<find>.
# Show type of random child element
say $dom->children->shuffle->first->type;
Expand All @@ -536,8 +536,9 @@ C<charset> has been defined.
my $collection = $dom->find('html title');
Find elements with CSS selectors and return a L<Mojo::Collection> object. All
selectors from L<Mojo::DOM::CSS> are supported.
Find elements with CSS selectors and return a L<Mojo::Collection> object
containing these elements as L<Mojo::DOM> objects. All selectors from
L<Mojo::DOM::CSS> are supported.
# Find a specific element and extract information
my $id = $dom->find('div')->[23]{id};
Expand All @@ -561,7 +562,7 @@ Find element namespace.
my $sibling = $dom->next;
Next sibling of element.
Return L<Mojo::DOM> object for next sibling of element.
# "<h2>B</h2>"
$dom->parse('<div><h1>A</h1><h2>B</h2></div>')->at('h1')->next;
Expand All @@ -570,7 +571,7 @@ Next sibling of element.
my $parent = $dom->parent;
Parent of element.
Return L<Mojo::DOM> object for parent of element.
=head2 parse
Expand Down Expand Up @@ -603,7 +604,7 @@ Prepend to element content.
my $sibling = $dom->previous;
Previous sibling of element.
Return L<Mojo::DOM> object for previous sibling of element.
# "<h1>A</h1>"
$dom->parse('<div><h1>A</h1><h2>B</h2></div>')->at('h2')->previous;
Expand All @@ -612,7 +613,7 @@ Previous sibling of element.
my $old = $dom->remove;
Remove element.
Remove element and return it as a L<Mojo::DOM> object.
# "<div></div>"
$dom->parse('<div><h1>A</h1></div>')->at('h1')->remove->root;
Expand All @@ -621,7 +622,7 @@ Remove element.
my $old = $dom->replace('<div>test</div>');
Replace element.
Replace element and return the replaced element as a L<Mojo::DOM> object.
# "<div><h2>B</h2></div>"
$dom->parse('<div><h1>A</h1></div>')->at('h1')->replace('<h2>B</h2>')->root;
Expand All @@ -645,7 +646,7 @@ Replace element content.
my $root = $dom->root;
Find root node.
Return L<Mojo::DOM> object for root node.
=head2 text
Expand Down

0 comments on commit 3318bcb

Please sign in to comment.