@colyseus/schema 3.0.71 → 3.0.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3561,14 +3561,27 @@ function schema(fieldsAndMethods, name, inherits = Schema) {
3561
3561
  }
3562
3562
  return defaults;
3563
3563
  };
3564
+ const getParentProps = (props) => {
3565
+ const fieldNames = Object.keys(fields);
3566
+ const parentProps = {};
3567
+ for (const key in props) {
3568
+ if (!fieldNames.includes(key)) {
3569
+ parentProps[key] = props[key];
3570
+ }
3571
+ }
3572
+ return parentProps;
3573
+ };
3564
3574
  /** @codegen-ignore */
3565
3575
  const klass = Metadata.setFields(class extends inherits {
3566
3576
  constructor(...args) {
3567
- super(Object.assign({}, getDefaultValues(), args[0] || {}));
3568
3577
  // call initialize method
3569
3578
  if (methods.initialize && typeof methods.initialize === 'function') {
3579
+ super(Object.assign({}, getDefaultValues(), getParentProps(args[0] || {})));
3570
3580
  methods.initialize.apply(this, args);
3571
3581
  }
3582
+ else {
3583
+ super(Object.assign({}, getDefaultValues(), args[0] || {}));
3584
+ }
3572
3585
  }
3573
3586
  }, fields);
3574
3587
  // Store the getDefaultValues function on the class for inheritance