wip: make singleton mutations affect all app instances
This commit is contained in:
@@ -6,6 +6,8 @@ import {
|
||||
deprecationData,
|
||||
toggleDeprecationWarning
|
||||
} from '../../runtime-core/src/compat/compatConfig'
|
||||
import { singletonApp } from '../../runtime-core/src/compat/global'
|
||||
import { createApp } from '../src/esm-index'
|
||||
|
||||
beforeEach(() => {
|
||||
toggleDeprecationWarning(false)
|
||||
@@ -280,6 +282,15 @@ describe('GLOBAL_PROTOTYPE', () => {
|
||||
const plain = new Vue() as any
|
||||
expect(plain.$test).toBeUndefined()
|
||||
})
|
||||
|
||||
test('should affect apps created via createApp()', () => {
|
||||
Vue.prototype.$test = 1
|
||||
const vm = createApp({
|
||||
template: 'foo'
|
||||
}).mount(document.createElement('div')) as any
|
||||
expect(vm.$test).toBe(1)
|
||||
delete Vue.prototype.$test
|
||||
})
|
||||
})
|
||||
|
||||
describe('GLOBAL_SET/DELETE', () => {
|
||||
@@ -381,3 +392,12 @@ describe('GLOBAL_PRIVATE_UTIL', () => {
|
||||
expect(n).toBe(2)
|
||||
})
|
||||
})
|
||||
|
||||
test('global asset registration should affect apps created via createApp', () => {
|
||||
Vue.component('foo', { template: 'foo' })
|
||||
const vm = createApp({
|
||||
template: '<foo/>'
|
||||
}).mount(document.createElement('div')) as any
|
||||
expect(vm.$el.textContent).toBe('foo')
|
||||
delete singletonApp._context.components.foo
|
||||
})
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import Vue from '@vue/compat'
|
||||
import { toggleDeprecationWarning } from '../../runtime-core/src/compat/compatConfig'
|
||||
import { createApp } from '../src/esm-index'
|
||||
import { triggerEvent } from './utils'
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -64,3 +65,12 @@ test('GLOBAL_IGNORED_ELEMENTS', () => {
|
||||
})
|
||||
expect(el.innerHTML).toBe(`<v-foo></v-foo><foo></foo>`)
|
||||
})
|
||||
|
||||
test('singleton config should affect apps created with createApp()', () => {
|
||||
Vue.config.ignoredElements = [/^v-/, 'foo']
|
||||
const el = document.createElement('div')
|
||||
createApp({
|
||||
template: `<v-foo/><foo/>`
|
||||
}).mount(el)
|
||||
expect(el.innerHTML).toBe(`<v-foo></v-foo><foo></foo>`)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user