]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: fix root data option compat
authorEvan You <yyx990803@gmail.com>
Tue, 6 Apr 2021 19:02:07 +0000 (15:02 -0400)
committerEvan You <yyx990803@gmail.com>
Wed, 7 Apr 2021 20:19:24 +0000 (16:19 -0400)
packages/runtime-core/src/compat/global.ts

index e3d860a907356b62e3c31b03449c390b9cd651fb..b475a6595a191ba2897b29a0c4f6902695d03d6d 100644 (file)
@@ -93,6 +93,12 @@ export function createCompatVue(
   const singletonApp = createApp({})
 
   function createCompatApp(options: ComponentOptions = {}, Ctor: any) {
+    const { data } = options
+    if (data && !isFunction(data)) {
+      __DEV__ && warnDeprecation(DeprecationTypes.OPTIONS_DATA_FN)
+      options.data = () => data
+    }
+
     const app = createApp(options)
 
     // copy over asset registries and deopt flag
@@ -142,14 +148,9 @@ export function createCompatVue(
       if (!inlineOptions) {
         return createCompatApp(options, SubVue)
       } else {
-        const { el, data } = inlineOptions
-        if (data && !isFunction(data)) {
-          __DEV__ && warnDeprecation(DeprecationTypes.OPTIONS_DATA_FN)
-          inlineOptions.data = () => data
-        }
         return createCompatApp(
           {
-            el,
+            el: inlineOptions.el,
             extends: options,
             mixins: [inlineOptions]
           },