This commit is contained in:
Yavor Georgiev 2017-02-02 02:41:11 +01:00 committed by GitHub
parent 36dd43b3b2
commit 19f00e1b4b
2 changed files with 15 additions and 4 deletions

View File

@ -25,10 +25,21 @@ let getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || function(obj
}, {});
};
function setConstructorOnPrototype(klass) {
if (klass.prototype.constructor !== klass) {
Object.defineProperty(klass.prototype, 'constructor', { value: klass, configurable: true, writable: true });
}
}
module.exports = function(realmConstructor) {
// Add the specified Array methods to the Collection prototype.
Object.defineProperties(realmConstructor.Collection.prototype, require('./collection-methods'));
setConstructorOnPrototype(realmConstructor.Collection);
setConstructorOnPrototype(realmConstructor.List);
setConstructorOnPrototype(realmConstructor.Results);
setConstructorOnPrototype(realmConstructor.Object);
// Add sync methods
if (realmConstructor.Sync) {
let userMethods = require('./user-methods');
@ -51,6 +62,9 @@ module.exports = function(realmConstructor) {
process.exit(99);
});
}
setConstructorOnPrototype(realmConstructor.Sync.User);
setConstructorOnPrototype(realmConstructor.Sync.Session);
}
// TODO: Remove this now useless object.

View File

@ -48,10 +48,7 @@ class ObjectWrap {
}
static JSObjectRef create_constructor(JSContextRef ctx) {
JSObjectRef constructor = JSObjectMake(ctx, get_constructor_class(), nullptr);
JSObjectRef prototype = (JSObjectRef)Object::get_property(ctx, constructor, "prototype");
Object::set_property(ctx, prototype, "constructor", constructor);
return constructor;
return JSObjectMake(ctx, get_constructor_class(), nullptr);
}
static JSClassRef get_class() {