Better support in pretty printer when an object has null prototype
- Fixes #500
This commit is contained in:
@@ -1390,7 +1390,7 @@ getJasmineRequireObj().pp = function(j$) {
|
|||||||
|
|
||||||
PrettyPrinter.prototype.iterateObject = function(obj, fn) {
|
PrettyPrinter.prototype.iterateObject = function(obj, fn) {
|
||||||
for (var property in obj) {
|
for (var property in obj) {
|
||||||
if (!obj.hasOwnProperty(property)) { continue; }
|
if (!Object.prototype.hasOwnProperty.call(obj, property)) { continue; }
|
||||||
if (property == '__Jasmine_been_here_before__') { continue; }
|
if (property == '__Jasmine_been_here_before__') { continue; }
|
||||||
fn(property, obj.__lookupGetter__ ? (!j$.util.isUndefined(obj.__lookupGetter__(property)) &&
|
fn(property, obj.__lookupGetter__ ? (!j$.util.isUndefined(obj.__lookupGetter__(property)) &&
|
||||||
obj.__lookupGetter__(property) !== null) : false);
|
obj.__lookupGetter__(property) !== null) : false);
|
||||||
|
|||||||
@@ -121,5 +121,12 @@ describe("j$.pp", function () {
|
|||||||
|
|
||||||
expect(j$.pp(obj)).toEqual("strung");
|
expect(j$.pp(obj)).toEqual("strung");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should handle objects with null prototype", function() {
|
||||||
|
var obj = Object.create(null);
|
||||||
|
obj.foo = 'bar';
|
||||||
|
|
||||||
|
expect(j$.pp(obj)).toEqual("{ foo : 'bar' }");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ getJasmineRequireObj().pp = function(j$) {
|
|||||||
|
|
||||||
PrettyPrinter.prototype.iterateObject = function(obj, fn) {
|
PrettyPrinter.prototype.iterateObject = function(obj, fn) {
|
||||||
for (var property in obj) {
|
for (var property in obj) {
|
||||||
if (!obj.hasOwnProperty(property)) { continue; }
|
if (!Object.prototype.hasOwnProperty.call(obj, property)) { continue; }
|
||||||
if (property == '__Jasmine_been_here_before__') { continue; }
|
if (property == '__Jasmine_been_here_before__') { continue; }
|
||||||
fn(property, obj.__lookupGetter__ ? (!j$.util.isUndefined(obj.__lookupGetter__(property)) &&
|
fn(property, obj.__lookupGetter__ ? (!j$.util.isUndefined(obj.__lookupGetter__(property)) &&
|
||||||
obj.__lookupGetter__(property) !== null) : false);
|
obj.__lookupGetter__(property) !== null) : false);
|
||||||
|
|||||||
Reference in New Issue
Block a user