Skip to content
Snippets Groups Projects
Commit c98c73b1 authored by mcmlxxix's avatar mcmlxxix
Browse files

JPath.$$() now returns an array of JPath objects (instead of a single JPath...

JPath.$$() now returns an array of JPath objects (instead of a single JPath object containing an array)
parent b8ba3372
Branches
Tags
No related merge requests found
......@@ -62,6 +62,12 @@
1.0.5 - Bugfix for greedy regexp
*/
/* $id: $
mcmlxxix wuz here '13
*/
function JPath( json, parent ) {
this.json = json;
this._parent = parent;
......@@ -157,21 +163,21 @@ JPath.prototype = {
*/
'$$': function( str ) {
var r = this.$(str,true).json;
var r = this.$(str,true);
var arr = new Array();
if ( r instanceof Array )
if ( r.json instanceof Array )
arr = arr.concat(r);
else if ( r !== null )
else if ( r.json !== null )
arr.push(r);
for ( var p in this.json ) {
if ( typeof( this.json[p] ) == 'object' ) {
arr = arr.concat( new JPath( this.json[p], this ).$$(str).json );
arr = arr.concat( new JPath( this.json[p], this ).$$(str));
}
}
return new JPath( arr, this );
return arr;
},
/*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment