]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: basic compat test
authorEvan You <yyx990803@gmail.com>
Tue, 6 Apr 2021 16:17:17 +0000 (12:17 -0400)
committerEvan You <yyx990803@gmail.com>
Wed, 7 Apr 2021 20:19:24 +0000 (16:19 -0400)
jest.config.js
packages/runtime-core/src/compat/__tests__/compatGlobal.spec.ts
packages/runtime-core/src/compat/customDirective.ts
packages/runtime-core/src/compat/deprecations.ts
packages/runtime-core/src/compat/global.ts
tsconfig.json

index 7ec66b39d15e373477b6b33a2d93aae7d9eb678a..306ed5f0379f73dcea12617fdc742ba54b3b4622 100644 (file)
@@ -35,6 +35,7 @@ module.exports = {
   watchPathIgnorePatterns: ['/node_modules/', '/dist/', '/.git/'],
   moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
   moduleNameMapper: {
+    '@vue/compat': '<rootDir>/packages/vue-compat/src',
     '^@vue/(.*?)$': '<rootDir>/packages/$1/src',
     vue: '<rootDir>/packages/vue/src'
   },
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..d4e94433d8cd4e069f9cdd955d7a0ad51cd636a1 100644 (file)
@@ -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')
+})
index f7ae36ec14de67666be97d8195c9de22a4c9c090..fba2573aa5e4f535525e171ce28ee9ea8a5499ee 100644 (file)
@@ -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'
 
index 4dda842d64ab48046c767232a8c4b0120da2cffe..6cadda92452d812a1279730e5fa1135303960c43 100644 (file)
@@ -122,7 +122,7 @@ const deprecations: Record<DeprecationTypes, DeprecationData> = {
 
   [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`
   },
index 68b1bb53aecd49c23d24a7f56c2eab8d22c7d293..e3d860a907356b62e3c31b03449c390b9cd651fb 100644 (file)
@@ -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
index 117bce3edf97e712f62f084e769de5a8ce44e7c4..cb22e063f38395e63eefe53b1a837a9ef863d363 100644 (file)
@@ -18,6 +18,7 @@
     "types": ["jest", "puppeteer", "node"],
     "rootDir": ".",
     "paths": {
+      "@vue/compat": ["packages/vue-compat/src"],
       "@vue/*": ["packages/*/src"],
       "vue": ["packages/vue/src"]
     }