Open rmarlow opened 9 years ago
node is v0.10.33, OS is Ubuntu 12.04.4
I've followed it back to a point in the code where there's a var that is a reference to a function is being called with arguments. In browser (Chrome Version 40.0.2214.111 m), it works fine and calls the referenced function properly, and I can also console.log the var and see the contents of the function it should be calling. But in node-qunit-phantomjs, I keep getting an error thrown as soon as I try to console.log the var or call the function that it references. The error is being thrown at the line return fromArray + '{' + newLine + prettyObject(element, indent) + indent + '}';
this.prettyPrint = function (jsObject, indentLength, outputTo, fullFunction) {
//adapted from https://github.com/cvadillo/js-object-pretty-print
"use strict";
...
prettyObjectPrint = function (object, indent) {
var value = [],
property;
indent += indentString;
for (property in object) {
if (object.hasOwnProperty(property)) {
value.push(indent + property + ': ' + pretty(object[property], indent));
}
}
return value.join(newLineJoin) + newLine;
};
...
pretty = function (element, indent, fromArray) {
...
switch (type) {
...
case 'object':
if (element === null) {
return fromArray + '"null"';
} else {
visited.push(element);
return fromArray + '{' + newLine + prettyObject(element, indent) + indent + '}';
}
...
}
};
if (indentLength === undefined) {
indentLength = 4;
}
...
prettyObject = outputTo === 'json' ? prettyObjectJSON : prettyObjectPrint;
...
return pretty(jsObject, '');
};
+1, same problem here with 1.2.0 on Node.js v0.12.2.
I'm testing some code of mine that seems to have an error in it. It works fine in a browser, but it errors in node-qunit-phantomjs. When the error is thrown though, my error results in another error within node-qunit-phantomjs, like so:
Looking at the source, the "this" keyword seems to not be pointing at what it thinks it is. I'm going to proceed trying to debug my own code for what is throwing the original error, but do you have any clues as to why the "this" keyword is not in the correct scope here, or a possible fix?