Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle remote arguments with no constructor #6369

Merged
merged 6 commits into from Jul 7, 2016
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/renderer/api/remote.js
Expand Up @@ -60,7 +60,7 @@ var wrapArgs = function (args, visited) {

ret = {
type: 'object',
name: value.constructor.name,
name: value.constructor != null ? value.constructor.name : 'Object',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chetverikov I tweaked your change a bit here to return an empty name when constructor.name is empty since that would seem to be the expected behavior for anonymous classes like new (class {}).

members: []
}
for (prop in value) {
Expand Down
2 changes: 2 additions & 0 deletions spec/api-ipc-spec.js
Expand Up @@ -34,6 +34,8 @@ describe('ipc module', function () {
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(new (class {})), '')
})

it('should search module from the user app', function () {
Expand Down
8 changes: 7 additions & 1 deletion spec/fixtures/module/no-prototype.js
@@ -1,4 +1,10 @@
const foo = Object.create(null)
foo.bar = 'baz'
foo.baz = false
module.exports = {foo: foo, bar: 1234}
module.exports = {
foo: foo,
bar: 1234,
getConstructorName: function (value) {
return value.constructor.name
}
}