@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.
@@ -3559,14 +3559,27 @@ function schema(fieldsAndMethods, name, inherits = Schema) {
3559
3559
  }
3560
3560
  return defaults;
3561
3561
  };
3562
+ const getParentProps = (props) => {
3563
+ const fieldNames = Object.keys(fields);
3564
+ const parentProps = {};
3565
+ for (const key in props) {
3566
+ if (!fieldNames.includes(key)) {
3567
+ parentProps[key] = props[key];
3568
+ }
3569
+ }
3570
+ return parentProps;
3571
+ };
3562
3572
  /** @codegen-ignore */
3563
3573
  const klass = Metadata.setFields(class extends inherits {
3564
3574
  constructor(...args) {
3565
- super(Object.assign({}, getDefaultValues(), args[0] || {}));
3566
3575
  // call initialize method
3567
3576
  if (methods.initialize && typeof methods.initialize === 'function') {
3577
+ super(Object.assign({}, getDefaultValues(), getParentProps(args[0] || {})));
3568
3578
  methods.initialize.apply(this, args);
3569
3579
  }
3580
+ else {
3581
+ super(Object.assign({}, getDefaultValues(), args[0] || {}));
3582
+ }
3570
3583
  }
3571
3584
  }, fields);
3572
3585
  // Store the getDefaultValues function on the class for inheritance