test: fix mixin case

This commit is contained in:
Evan You 2019-02-26 21:45:13 -05:00
parent ff9cddd46f
commit e151d34100
3 changed files with 6 additions and 8 deletions

View File

@ -145,6 +145,7 @@ class InternalComponent implements PublicInstanceMethods {
// so that the extended class constructor (and property initializers) can // so that the extended class constructor (and property initializers) can
// access $props. // access $props.
this.$props = props this.$props = props
Object.assign(this, props)
} }
if (__COMPAT__) { if (__COMPAT__) {
;(this as any)._eventEmitter = new EventEmitter(this) ;(this as any)._eventEmitter = new EventEmitter(this)

View File

@ -47,11 +47,9 @@ export function initializeProps(
// expose initial props on the raw instance so that they can be accessed // expose initial props on the raw instance so that they can be accessed
// in the child class constructor by class field initializers. // in the child class constructor by class field initializers.
if (options != null) { if (options != null) {
for (const key in props) { // it's okay to just set it here because props options are normalized
// it's okay to just set it here because props options are normalized // and reserved keys should have been filtered away
// and reserved keys should have been filtered away Object.assign(instance, props)
;(instance as any)[key] = props[key]
}
} }
} }

View File

@ -20,12 +20,11 @@ export function extractInitializers(
data: any = {} data: any = {}
): any { ): any {
const keys = Object.keys(instance) const keys = Object.keys(instance)
const props = instance.$options.props const props = instance.$props
for (let i = 0; i < keys.length; i++) { for (let i = 0; i < keys.length; i++) {
const key = keys[i] const key = keys[i]
if (!isReservedKey(key)) { if (!isReservedKey(key)) {
// it's possible for a prop to be present here when it's declared if (!props.hasOwnProperty(key)) {
if (!props || !props.hasOwnProperty(key)) {
data[key] = (instance as any)[key] data[key] = (instance as any)[key]
} }
} }