Skip to content

Commit efb3913

Browse files
committed
add a test
1 parent b506512 commit efb3913

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@
3434
var props = booleanProps.concat(numericProps, stringProps, arrayProps);
3535

3636
function StackFrame(obj) {
37+
if (!obj) return;
3738
for (var i = 0; i < props.length; i++) {
38-
if (obj && obj[props[i]] !== undefined) {
39+
if (obj[props[i]] !== undefined) {
3940
this['set' + _capitalize(props[i])](obj[props[i]]);
4041
}
4142
}

0 commit comments

Comments
 (0)