Skip to content

Commit c824372

Browse files
aiskleeyeh
authored andcommitted
fix(Object): don't copy any property descriptor in utils.inherits (#508)
1 parent 71ce83f commit c824372

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/object.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,9 @@ module.exports = function(AV) {
14061406
var newArguments = [className].concat(_.toArray(arguments));
14071407
return AV.Object.extend.apply(NewClassObject, newArguments);
14081408
};
1409-
NewClassObject['new'] = function(attributes, options) {
1409+
// Add the query property descriptor.
1410+
Object.defineProperty(NewClassObject, 'query', Object.getOwnPropertyDescriptor(AV.Object, 'query'));
1411+
NewClassObject['new'] = function (attributes, options) {
14101412
return new NewClassObject(attributes, options);
14111413
};
14121414
AV.Object._classMap[className] = NewClassObject;

src/utils/index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,11 @@ const inherits = function inherits(parent, protoProps, staticProps) {
103103
child = protoProps.constructor;
104104
} else {
105105
/** @ignore */
106-
child = function(){ parent.apply(this, arguments); };
106+
child = function() { parent.apply(this, arguments); };
107107
}
108108

109109
// Inherit class (static) properties from parent.
110-
for (const prop of Object.getOwnPropertyNames(parent)) {
111-
const propertyDescriptor = Object.getOwnPropertyDescriptor(parent, prop);
112-
Object.defineProperty(child, prop, propertyDescriptor);
113-
}
110+
_.extend(child, parent);
114111

115112
// Set the prototype chain to inherit from `parent`, without calling
116113
// `parent`'s constructor function.

0 commit comments

Comments
 (0)