-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
devtools support for defineCustomElement #4356
Comments
cc @Akryum |
I'm far from in-depth with the core functionality of vue. But I did some digging and posting it here in case it is helpful. 🙈 The dev tools isn't showing since no apps are registered with the dev tools. If you mount a regular vue app on the same page it will show normally, but only have the regular app registered. Regular vue registers the apps on the if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
app._instance = vnode.component
devtoolsInitApp(app, version)
} It is then removed from devtools on if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
app._instance = null
devtoolsUnmountApp(app)
} As @soultice mentions it looks natural to put it as part of The devtools methods aren't exported from The As I see it either the customElement needs to be wraped or transformed to an app type to be registered as a regular vue app is. |
my solution to whom ever who will need this
The line devtools.emit('app:init', vueService.CurrentApp, version, {Fragment, Text, Comment, Static}); is emitting an event to mount the Vue devtools to the browser. The event is named "app:init" and it takes in arguments the current app instance (vueService.CurrentApp), the version of Vue being used, and the symbols for Fragment, Text, Comment, and Static. The line devtools.emit('app:unmount', vueService.CurrentApp); is emitting an event to unmount the Vue devtools from the browser. The event is named "app:unmount" and it takes in argument the current app instance (vueService.CurrentApp). |
hi DBTK1990, |
yes it is but you dont need all of it to do it,
you can just emit the event with the current app
do you have discord?
you can use this event with the vue app
devtools.emit('app:init', vueService.CurrentApp, version, {
Fragment,
Text,
Comment,
Static
});
…On Wed, 1 Mar 2023 at 12:37, larry ***@***.***> wrote:
hi DBTK1990,
Could you explain just a bit how to use your script ! my entire app is
mounted in an shadowdom target and my expectation is that I can use the
VueDevTool to inpect Vue component, is your script aim for that ?
—
Reply to this email directly, view it on GitHub
<#4356 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEXKOFCPHCSKQTD6TLYX5V3WZ4RH7ANCNFSM5CIBEKLQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Hi DBTK1990, As I said, my entire app is attached to a shadowRoot tag, as shown in the simplified code below, I just added your code by replacing VueDevtools works in this config (Pinia ok, cool!), but there is something that doesn't work which is very practical in a teamwork, it's to be able to inspect the tree of Vue components (mouse hover) and highlight them in the browser. This makes it possible to understand the nesting of the components. Unfortunately, it still does not work ;( //--- all the bootstrap code here ....
const app = createApp(App);
//---- Shadow
let targetShadow = document.getElementById("app");
const shadowRoot = targetShadow!.attachShadow({ mode: 'open' });
//--- Append Vue app
const appNode = document.createElement("div");
shadowRoot.append(appNode);
//--- Mount Vue.js App
app.mount(appNode);
//--- Your code
devtools.emit('app:init', app, version, {
Fragment,
Text,
Comment,
Static
});
... |
Hello, I solved it like this
|
Closed via 6758c3c |
What problem does this feature solve?
Thank you for the great work on the
defineCustomElements
. I'm really enjoying this feature, and I'm sure many others so so as well.Unfortunately the devtools are currently unable to find any components created with
defineCustomElements
.From a quick glance it seems they are initialized with the
.mount()
method of an app, whichdefineCustomElements
does not make use of.It would be a really nice addition if we were able to debug our components with the vuejs devtools.
What does the proposed API look like?
I'm not that in-depth with vue behind the scenes. Maybe it would be possible to hook into
connectedCallback
anddisconnectedCallback
to initialize devtools?The text was updated successfully, but these errors were encountered: