Skip to content

Commit 648a59f

Browse files
committed
Move invocation of initialize above setting of attributes
1 parent 4499860 commit 648a59f

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/ParseObject.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ export default class ParseObject {
9999
className: string;
100100

101101
constructor(className: ?string | { className: string, [attr: string]: mixed }, attributes?: { [attr: string]: mixed }, options?: { ignoreValidation: boolean }) {
102+
// Enable legacy initializers
103+
if (typeof this.initialize === 'function') {
104+
this.initialize.apply(this, arguments);
105+
}
106+
102107
var toSet = null;
103108
this._objCount = objectCount++;
104109
if (typeof className === 'string') {
@@ -121,10 +126,6 @@ export default class ParseObject {
121126
if (toSet && !this.set(toSet, options)) {
122127
throw new Error('Can\'t create an invalid Parse Object');
123128
}
124-
// Enable legacy initializers
125-
if (typeof this.initialize === 'function') {
126-
this.initialize.apply(this, arguments);
127-
}
128129
}
129130

130131
/** Prototype getters / setters **/
@@ -1366,17 +1367,18 @@ export default class ParseObject {
13661367
parentProto = classMap[adjustedClassName].prototype;
13671368
}
13681369
var ParseObjectSubclass = function(attributes, options) {
1370+
// Enable legacy initializers
1371+
if (typeof this.initialize === 'function') {
1372+
this.initialize.apply(this, arguments);
1373+
}
1374+
13691375
this.className = adjustedClassName;
13701376
this._objCount = objectCount++;
13711377
if (attributes && typeof attributes === 'object'){
13721378
if (!this.set(attributes || {}, options)) {
13731379
throw new Error('Can\'t create an invalid Parse Object');
13741380
}
13751381
}
1376-
// Enable legacy initializers
1377-
if (typeof this.initialize === 'function') {
1378-
this.initialize.apply(this, arguments);
1379-
}
13801382
};
13811383
ParseObjectSubclass.className = adjustedClassName;
13821384
ParseObjectSubclass.__super__ = parentProto;

0 commit comments

Comments
 (0)