From: Evan You Date: Tue, 6 Apr 2021 19:02:07 +0000 (-0400) Subject: wip: fix root data option compat X-Git-Tag: v3.1.0-beta.1~59^2~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=926e12862bbafe78cd200a6483f77afeb03b3e6e;p=thirdparty%2Fvuejs%2Fcore.git wip: fix root data option compat --- diff --git a/packages/runtime-core/src/compat/global.ts b/packages/runtime-core/src/compat/global.ts index e3d860a907..b475a6595a 100644 --- a/packages/runtime-core/src/compat/global.ts +++ b/packages/runtime-core/src/compat/global.ts @@ -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] },