Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add an optional mapping parameter to ->__xpath(), without test

  • Loading branch information...
commit 8d9c8a32437c5ce337b042974b139a58e0ac41a3 1 parent 403f418
Max Maischein authored
Showing with 11 additions and 4 deletions.
  1. +11 −4 lib/MozRepl/RemoteObject.pm
View
15 lib/MozRepl/RemoteObject.pm
@@ -1364,21 +1364,28 @@ on HTMLdocument nodes.
=cut
sub __xpath {
- my ($self,$query,$ref) = @_; # $self is a HTMLdocument
+ my ($self,$query,$ref,$cont) = @_; # $self is a HTMLdocument
$ref ||= $self;
my $js = <<'JS';
- function(doc,q,ref) {
+ function(doc,q,ref,cont) {
var xres = doc.evaluate(q,ref,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );
+ var map;
+ if( cont ) {
+ map = cont;
+ } else {
+ // Default is identity
+ map = function(e){ return e };
+ };
var res = [];
for ( var i=0 ; i < xres.snapshotLength; i++ )
{
- res.push( xres.snapshotItem(i));
+ res.push( map(xres.snapshotItem(i)));
};
return res
}
JS
my $snap = $self->bridge->declare($js,'list');
- $snap->($self,$query,$ref);
+ $snap->($self,$query,$ref,$cont);
}
=head2 C<< $obj->__click >>
Please sign in to comment.
Something went wrong with that request. Please try again.