Skip to content

Commit 0fa3f2f

Browse files
committed
debugger: Correctly eval arrays and numbers
1 parent 533797a commit 0fa3f2f

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

lib/_debugger.js

+18-4
Original file line numberDiff line numberDiff line change
@@ -406,18 +406,32 @@ Client.prototype.mirrorObject = function(handle, cb) {
406406
return;
407407
}
408408

409-
var mirror = {};
409+
var mirror;
410+
if (handle.className == 'Array') {
411+
mirror = [];
412+
} else {
413+
mirror = {};
414+
}
415+
410416
for (var i = 0; i < handle.properties.length; i++) {
411417
var value = res.body[handle.properties[i].ref];
412-
mirror[handle.properties[i].name] = value.text;
418+
var mirrorValue = value.value ? value.value : value.text;
419+
420+
if (Array.isArray(mirror) &&
421+
typeof handle.properties[i].name != 'number') {
422+
// Skip the 'length' property.
423+
continue;
424+
}
425+
426+
mirror[handle.properties[i].name] = mirrorValue;
413427
}
414428

415429
if (cb) cb(mirror);
416430
});
417431

418-
} else if (handle.type == 'string') {
432+
} else if (handle.value) {
419433
process.nextTick(function() {
420-
cb(handle.text);
434+
cb(handle.value);
421435
});
422436

423437
} else {

0 commit comments

Comments
 (0)