// so that the extended class constructor (and property initializers) can
// access $props.
this.$props = props
+ Object.assign(this, props)
}
if (__COMPAT__) {
;(this as any)._eventEmitter = new EventEmitter(this)
// expose initial props on the raw instance so that they can be accessed
// in the child class constructor by class field initializers.
if (options != null) {
- for (const key in props) {
- // it's okay to just set it here because props options are normalized
- // and reserved keys should have been filtered away
- ;(instance as any)[key] = props[key]
- }
+ // it's okay to just set it here because props options are normalized
+ // and reserved keys should have been filtered away
+ Object.assign(instance, props)
}
}
data: any = {}
): any {
const keys = Object.keys(instance)
- const props = instance.$options.props
+ const props = instance.$props
for (let i = 0; i < keys.length; i++) {
const key = keys[i]
if (!isReservedKey(key)) {
- // it's possible for a prop to be present here when it's declared
- if (!props || !props.hasOwnProperty(key)) {
+ if (!props.hasOwnProperty(key)) {
data[key] = (instance as any)[key]
}
}