]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test: fix mixin case
authorEvan You <yyx990803@gmail.com>
Wed, 27 Feb 2019 02:45:13 +0000 (21:45 -0500)
committerEvan You <yyx990803@gmail.com>
Wed, 27 Feb 2019 02:45:13 +0000 (21:45 -0500)
packages/runtime-core/src/component.ts
packages/runtime-core/src/componentProps.ts
packages/runtime-core/src/componentState.ts

index 83d865522fc423a9a8a6971927cd5a11d774f4a6..6e00f3914c5ca3f6d213914badc43fcd10904ad0 100644 (file)
@@ -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)
index 91defca4e39f2943f92ced3513d299527b9598fb..044bfd754f4b9dadc7b676df2909381c627910d2 100644 (file)
@@ -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)
   }
 }
 
index b5ed9d4da96671b314b5932667b52fba5fc890e9..74beb5fea4a94125467366e1cbe30c6f13d4dacb 100644 (file)
@@ -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]
       }
     }