Created
September 25, 2010 13:36
-
-
Save marcusramberg/596843 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Mojo/Message.pm b/lib/Mojo/Message.pm | |
index 2b12ec2..60f2576 100644 | |
--- a/lib/Mojo/Message.pm | |
+++ b/lib/Mojo/Message.pm | |
@@ -240,7 +240,15 @@ sub dom { | |
and $charset = $1; | |
# Parse | |
- return $class->new(charset => $charset)->parse($self->body); | |
+ my $dom=$class->new(charset => $charset)->parse($self->body); | |
+ | |
+ # Shortcut for find? | |
+ my $selector=shift; | |
+ if (defined $selector) { | |
+ return $dom->find($selector); | |
+ } | |
+ | |
+ return $dom; | |
} | |
sub error { | |
@@ -784,8 +792,10 @@ Access message cookies. | |
=head2 C<dom> | |
my $dom = $message->dom; | |
+ my $res = $message->dom('a'); | |
-Parses content into a L<Mojo::DOM> object. | |
+Parses content into a L<Mojo::DOM> object. Take an optional selector | |
+to perform a find on the dom directly. | |
Note that this method is EXPERIMENTAL and might change without warning! | |
=head2 C<error> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment