From 41c162294c40f1bf266e0777296f46728d369bff Mon Sep 17 00:00:00 2001 From: Ang Long Date: Wed, 23 Aug 2017 16:01:28 +0800 Subject: [PATCH] fix: don't copy any property descriptor in utils.inherits --- src/object.js | 4 +++- src/utils/index.js | 7 ++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/object.js b/src/object.js index d30ed2dcf..d6aa8fa00 100644 --- a/src/object.js +++ b/src/object.js @@ -1406,7 +1406,9 @@ module.exports = function(AV) { var newArguments = [className].concat(_.toArray(arguments)); return AV.Object.extend.apply(NewClassObject, newArguments); }; - NewClassObject['new'] = function(attributes, options) { + // Add the query property descriptor. + Object.defineProperty(NewClassObject, 'query', Object.getOwnPropertyDescriptor(AV.Object, 'query')); + NewClassObject['new'] = function (attributes, options) { return new NewClassObject(attributes, options); }; AV.Object._classMap[className] = NewClassObject; diff --git a/src/utils/index.js b/src/utils/index.js index 3417bc56b..db7d9a95f 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -103,14 +103,11 @@ const inherits = function inherits(parent, protoProps, staticProps) { child = protoProps.constructor; } else { /** @ignore */ - child = function(){ parent.apply(this, arguments); }; + child = function() { parent.apply(this, arguments); }; } // Inherit class (static) properties from parent. - for (const prop of Object.getOwnPropertyNames(parent)) { - const propertyDescriptor = Object.getOwnPropertyDescriptor(parent, prop); - Object.defineProperty(child, prop, propertyDescriptor); - } + _.extend(child, parent); // Set the prototype chain to inherit from `parent`, without calling // `parent`'s constructor function.