Handle freezing with null values

This commit is contained in:
Matthew Findley 2015-08-03 10:37:26 -07:00
parent 6d3c4ae04a
commit 2f110e5a23
2 changed files with 8 additions and 0 deletions

View File

@ -1,4 +1,6 @@
function isFreezable(obj) { function isFreezable(obj) {
if (obj === null) return false;
return Array.isArray(obj) || return Array.isArray(obj) ||
typeof obj === 'object'; typeof obj === 'object';
} }

View File

@ -50,4 +50,10 @@ describe('freeze', () => {
expect(Object.isFrozen(obj)).to.be.false; expect(Object.isFrozen(obj)).to.be.false;
}); });
it('handles null objects', () => {
const obj = { foo: null };
freeze(obj);
expect(Object.isFrozen(obj)).to.be.true;
});
}); });