Open farcry550 opened 5 days ago
@farcry550 Nice, You've found the root cause of the problem. PR welcome!
An interesting workaround is to move configureApp into the component's options as shown by this repro. I'm not sure if this is intentional or of the repercussions.
This is a hidden usage, and it's correct.
https://github.com/vuejs/core/blob/352bc88c1bd2fda09c61ab17ea1a5967ffcd7bc0/packages/runtime-dom/src/apiCustomElement.ts#L176
Ultimately, configureApp
will be merged into def
PR welcome!
I’ll create one!
Vue version
3.5.12
Link to minimal reproduction
https://stackblitz.com/edit/vitejs-vite-b9enev?file=src%2Fmain.js
Steps to reproduce
app-injected
not displayed in the previewWhat is expected?
When given an async component,
defineCustomElement
with theconfigureApp
option results inconfigureApp
being called on the loaded component's mount.What is actually happening?
When given an async component,
defineCustomElement
with theconfigureApp
option does not result inconfigureApp
being called on the loaded component's mount.System Info
Any additional comments?
When resolving an async component, the component's loader is called and the loaded component is resolved.
https://github.com/vuejs/core/blob/06310e82f5bed62d1b9733dcb18cd8d6edc988de/packages/runtime-dom/src/apiCustomElement.ts#L404-L411
However, the
configureApp
function is attached to the async wrapper. When the component is loaded and the wrapper is discarded,configureApp
is discarded as well. Thus when the component is mounted,configureApp
is not called.https://github.com/vuejs/core/blob/06310e82f5bed62d1b9733dcb18cd8d6edc988de/packages/runtime-dom/src/apiCustomElement.ts#L401
https://github.com/vuejs/core/blob/06310e82f5bed62d1b9733dcb18cd8d6edc988de/packages/runtime-dom/src/apiCustomElement.ts#L414-L424
A fix here may be to assign the function from the wrapper to the loaded component before reassignment of
this._def
.An interesting workaround is to move
configureApp
into the component's options as shown by this repro. I'm not sure if this is intentional or of the repercussions.