Check toString after loading remote properties

This commit is contained in:
Kevin Sawicki 2017-03-17 10:29:07 -07:00
parent 648d3324fb
commit c50b518493

View file

@ -175,11 +175,16 @@ const proxyFunctionProperties = function (remoteMemberFunction, metaId, name) {
return true return true
}, },
get: (target, property, receiver) => { get: (target, property, receiver) => {
if (property === 'toString' && typeof target.toString === 'function') {
return target.toString.bind(target)
}
if (!target.hasOwnProperty(property)) loadRemoteProperties() if (!target.hasOwnProperty(property)) loadRemoteProperties()
return target[property] const value = target[property]
// Bind toString to target if it is a function to avoid
// Function.prototype.toString is not generic errors
if (property === 'toString' && typeof value === 'function') {
return value.bind(target)
}
return value
}, },
ownKeys: (target) => { ownKeys: (target) => {
loadRemoteProperties() loadRemoteProperties()