Skip to content

Commit e832bab

Browse files
committed
Merge branch 'pr/19'
2 parents aff47e4 + b44fdc2 commit e832bab

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

spec/stackframe-spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ describe('StackFrame', function() {
1313
};
1414
expect(fn).toThrow();
1515
});
16+
17+
it('works with objects with null prototype', function() {
18+
var obj = Object.create(null);
19+
obj.fileName = 'foo.js';
20+
obj.functionName = 'foo';
21+
obj.lineNumber = 1;
22+
obj.columnNumber = 42
23+
var sf = new StackFrame(obj);
24+
25+
expect(sf.fileName).toEqual('foo.js');
26+
});
1627
});
1728

1829
describe('#setFunctionName', function() {

stackframe.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@
3434
var props = booleanProps.concat(numericProps, stringProps, arrayProps);
3535

3636
function StackFrame(obj) {
37-
if (obj instanceof Object) {
38-
for (var i = 0; i < props.length; i++) {
39-
if (obj.hasOwnProperty(props[i]) && obj[props[i]] !== undefined) {
40-
this['set' + _capitalize(props[i])](obj[props[i]]);
41-
}
37+
if (!obj) return;
38+
for (var i = 0; i < props.length; i++) {
39+
if (obj[props[i]] !== undefined) {
40+
this['set' + _capitalize(props[i])](obj[props[i]]);
4241
}
4342
}
4443
}

0 commit comments

Comments
 (0)