From: Evan You Date: Wed, 27 Feb 2019 02:45:13 +0000 (-0500) Subject: test: fix mixin case X-Git-Tag: v3.0.0-alpha.0~1014 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e151d341007b3196fba89a3788b8b7746642f454;p=thirdparty%2Fvuejs%2Fcore.git test: fix mixin case --- diff --git a/packages/runtime-core/src/component.ts b/packages/runtime-core/src/component.ts index 83d865522f..6e00f3914c 100644 --- a/packages/runtime-core/src/component.ts +++ b/packages/runtime-core/src/component.ts @@ -145,6 +145,7 @@ class InternalComponent implements PublicInstanceMethods { // 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) diff --git a/packages/runtime-core/src/componentProps.ts b/packages/runtime-core/src/componentProps.ts index 91defca4e3..044bfd754f 100644 --- a/packages/runtime-core/src/componentProps.ts +++ b/packages/runtime-core/src/componentProps.ts @@ -47,11 +47,9 @@ export function initializeProps( // 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) } } diff --git a/packages/runtime-core/src/componentState.ts b/packages/runtime-core/src/componentState.ts index b5ed9d4da9..74beb5fea4 100644 --- a/packages/runtime-core/src/componentState.ts +++ b/packages/runtime-core/src/componentState.ts @@ -20,12 +20,11 @@ export function extractInitializers( 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] } }