Skip to content

Instantly share code, notes, and snippets.

Created December 28, 2012 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/43868b7f2326c2496775 to your computer and use it in GitHub Desktop.
Save anonymous/43868b7f2326c2496775 to your computer and use it in GitHub Desktop.
ugly hack to find to enable to return of Mojo::DOM objects rather than a colleciton
sub find {
my ($self, $selector, $dom) = @_;
# Match selector against tree
my $results = Mojo::DOM::CSS->new(tree => $self->tree)->select($selector);
# Upgrade results
@$results
= map { $self->new->charset($self->charset)->tree($_)->xml($self->xml) }
@$results;
return @$results if ($dom);
return Mojo::Collection->new(@$results);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment