From: Evan You Date: Tue, 6 Apr 2021 16:17:17 +0000 (-0400) Subject: wip: basic compat test X-Git-Tag: v3.1.0-beta.1~59^2~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d810eb4227f76c0bc2d74d75f9caea1e8a072a3;p=thirdparty%2Fvuejs%2Fcore.git wip: basic compat test --- diff --git a/jest.config.js b/jest.config.js index 7ec66b39d1..306ed5f037 100644 --- a/jest.config.js +++ b/jest.config.js @@ -35,6 +35,7 @@ module.exports = { watchPathIgnorePatterns: ['/node_modules/', '/dist/', '/.git/'], moduleFileExtensions: ['ts', 'tsx', 'js', 'json'], moduleNameMapper: { + '@vue/compat': '/packages/vue-compat/src', '^@vue/(.*?)$': '/packages/$1/src', vue: '/packages/vue/src' }, diff --git a/packages/runtime-core/src/compat/__tests__/compatGlobal.spec.ts b/packages/runtime-core/src/compat/__tests__/compatGlobal.spec.ts index e69de29bb2..d4e94433d8 100644 --- a/packages/runtime-core/src/compat/__tests__/compatGlobal.spec.ts +++ b/packages/runtime-core/src/compat/__tests__/compatGlobal.spec.ts @@ -0,0 +1,16 @@ +import Vue from '@vue/compat' + +test('should work', async () => { + const el = document.createElement('div') + el.innerHTML = `{{ msg }}` + new Vue({ + el, + data() { + return { + msg: 'hello' + } + } + }) + expect('global app bootstrapping API has changed').toHaveBeenWarned() + expect(el.innerHTML).toBe('hello') +}) diff --git a/packages/runtime-core/src/compat/customDirective.ts b/packages/runtime-core/src/compat/customDirective.ts index f7ae36ec14..fba2573aa5 100644 --- a/packages/runtime-core/src/compat/customDirective.ts +++ b/packages/runtime-core/src/compat/customDirective.ts @@ -1,4 +1,4 @@ -import { isArray } from '@vue/shared/src' +import { isArray } from '@vue/shared' import { ObjectDirective, DirectiveHook } from '../directives' import { DeprecationTypes, warnDeprecation } from './deprecations' diff --git a/packages/runtime-core/src/compat/deprecations.ts b/packages/runtime-core/src/compat/deprecations.ts index 4dda842d64..6cadda9245 100644 --- a/packages/runtime-core/src/compat/deprecations.ts +++ b/packages/runtime-core/src/compat/deprecations.ts @@ -122,7 +122,7 @@ const deprecations: Record = { [DeprecationTypes.INSTANCE_MOUNT]: { message: - `The global app boostrapping API has changed: vm.$mount() and the "el" ` + + `The global app bootstrapping API has changed: vm.$mount() and the "el" ` + `option have been removed. Use createApp(RootComponent).mount() instead.`, link: `https://v3.vuejs.org/guide/migration/global-api.html#mounting-app-instance` }, diff --git a/packages/runtime-core/src/compat/global.ts b/packages/runtime-core/src/compat/global.ts index 68b1bb53ae..e3d860a907 100644 --- a/packages/runtime-core/src/compat/global.ts +++ b/packages/runtime-core/src/compat/global.ts @@ -246,7 +246,7 @@ export function installCompatMount( if (hasNoRender) { instance.render = emptyRender } - setupComponent(instance, __NODE_JS__) + setupComponent(instance) vnode.component = instance // $mount & $destroy @@ -312,7 +312,7 @@ export function installCompatMount( } instance.render = null ;(component as ComponentOptions).template = container.innerHTML - finishComponentSetup(instance, __NODE_JS__, true /* skip options */) + finishComponentSetup(instance, false, true /* skip options */) } // clear content before mounting diff --git a/tsconfig.json b/tsconfig.json index 117bce3edf..cb22e063f3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,6 +18,7 @@ "types": ["jest", "puppeteer", "node"], "rootDir": ".", "paths": { + "@vue/compat": ["packages/vue-compat/src"], "@vue/*": ["packages/*/src"], "vue": ["packages/vue/src"] }