Use empty string constructor name when missing

This commit is contained in:
Kevin Sawicki 2016-07-06 13:06:48 -07:00
parent d67dfd09fd
commit a9b43a0fc9
2 changed files with 3 additions and 2 deletions

View file

@ -60,7 +60,7 @@ var wrapArgs = function (args, visited) {
ret = {
type: 'object',
name: value.constructor != null ? value.constructor.name : 'Object',
name: value.constructor != null ? value.constructor.name : '',
members: []
}
for (prop in value) {

View file

@ -31,10 +31,11 @@ describe('ipc module', function () {
it('should work when object has no prototype', function () {
var a = remote.require(path.join(fixtures, 'module', 'no-prototype.js'))
assert.equal(a.foo.constructor.name, '')
assert.equal(a.foo.bar, 'baz')
assert.equal(a.foo.baz, false)
assert.equal(a.bar, 1234)
assert.equal(a.getConstructorName(Object.create(null)), 'Object')
assert.equal(a.getConstructorName(Object.create(null)), '')
assert.equal(a.getConstructorName(new (class {})), '')
})