From c98c73b16896bd688315cf71da94fdc80d2c3b35 Mon Sep 17 00:00:00 2001 From: mcmlxxix <> Date: Thu, 28 Mar 2013 14:13:42 +0000 Subject: [PATCH] JPath.$$() now returns an array of JPath objects (instead of a single JPath object containing an array) --- exec/load/jpath.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/exec/load/jpath.js b/exec/load/jpath.js index 24a2084937..d8903f1edd 100644 --- a/exec/load/jpath.js +++ b/exec/load/jpath.js @@ -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; }, /* -- GitLab