configureApp
for defineCustomElement
Not Executed for Async Components
#12448
Labels
🔨 p3-minor-bug
Priority 3: this fixes a bug, but is an edge case that only affects very specific usage.
has workaround
A workaround has been found to avoid the problem
scope: custom elements
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
System: OS: Linux 5.15 Debian GNU/Linux 10 (buster) 10 (buster) CPU: (8) x64 Intel(R) Core(TM) i7-10610U CPU @ 1.80GHz Memory: 1.41 GB / 7.76 GB Container: Yes Shell: 5.0.3 - /bin/bash Binaries: Node: 16.20.2 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 8.19.4 - /usr/local/bin/npm npmPackages: vue: ^3.5.12 => 3.5.12
Any additional comments?
When resolving an async component, the component's loader is called and the loaded component is resolved.
core/packages/runtime-dom/src/apiCustomElement.ts
Lines 404 to 411 in 06310e8
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.core/packages/runtime-dom/src/apiCustomElement.ts
Line 401 in 06310e8
core/packages/runtime-dom/src/apiCustomElement.ts
Lines 414 to 424 in 06310e8
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.The text was updated successfully, but these errors were encountered: