Merge pull request #8890 from twolfson/dev/proxy.to.string.sqwished

🐛 Add toString support to remote functions
This commit is contained in:
Kevin Sawicki 2017-03-20 09:35:51 -07:00 committed by GitHub
commit 286f529968
3 changed files with 21 additions and 1 deletions

View file

@ -179,7 +179,15 @@ const proxyFunctionProperties = function (remoteMemberFunction, metaId, name) {
},
get: (target, property, receiver) => {
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) => {
loadRemoteProperties()