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({
const asyncDef = (this._def as ComponentOptions).__asyncLoader
if (asyncDef) {
- this._pendingResolve = asyncDef().then(def =>
- resolve((this._def = def), true),
- )
+ this._pendingResolve = asyncDef().then((def: InnerComponentDef) => {
+ def.configureApp = this._def.configureApp
+ resolve((this._def = def), true)
+ })
} else {
resolve(this._def)
}