|
|
@@ -1566,6 +1566,29 @@ describe('defineCustomElement', () => {
|
|
|
expect(e.shadowRoot?.innerHTML).toBe('<div>app-injected</div>')
|
|
|
})
|
|
|
|
|
|
+ // #12448
|
|
|
+ test('work with async component', async () => {
|
|
|
+ const AsyncComp = defineAsyncComponent(() => {
|
|
|
+ return Promise.resolve({
|
|
|
+ render() {
|
|
|
+ const msg: string | undefined = inject('msg')
|
|
|
+ return h('div', {}, msg)
|
|
|
+ },
|
|
|
+ } as any)
|
|
|
+ })
|
|
|
+ const E = defineCustomElement(AsyncComp, {
|
|
|
+ configureApp(app) {
|
|
|
+ app.provide('msg', 'app-injected')
|
|
|
+ },
|
|
|
+ })
|
|
|
+ customElements.define('my-async-element-with-app', E)
|
|
|
+
|
|
|
+ container.innerHTML = `<my-async-element-with-app></my-async-element-with-app>`
|
|
|
+ const e = container.childNodes[0] as VueElement
|
|
|
+ await new Promise(r => setTimeout(r))
|
|
|
+ expect(e.shadowRoot?.innerHTML).toBe('<div>app-injected</div>')
|
|
|
+ })
|
|
|
+
|
|
|
test('with hmr reload', async () => {
|
|
|
const __hmrId = '__hmrWithApp'
|
|
|
const def = defineComponent({
|