-
Notifications
You must be signed in to change notification settings - Fork 187
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
slots not correctly injected in Chrome and Opera #166
Comments
Hi, can You prepare example on e.g. https://codesandbox.io/s/jv4nvmp74v or GitHub repo? Also are you sure that you are using |
Hi karol-f, The issues with Chrome and Opera that I'm referring to only occur when I build the component (npm run build) and include the resulting js file (dist/HelloWorld.umd.min.js) in another website.
=> This works fine in Firefox and Edge, but not in Chrome and Opera |
Just FYI: it did work in Chrome and Opera until recently. |
Can You confirm that You are not double loading Vue library? |
Yes, I can confirm that. |
From a quick look there is invalid HTML in example above: If it's not causing it, can You please prepare GitHub repo with NOT working example and I will take a look at it? |
I'm sorry, the "}} shouldn't be there, that's probably a copy/paste issue. I'm not sure how I can prepare a GitHub repo. All there is to reproduce the issue is building the hello-world component as it is currently defined in the codesandbox link https://codesandbox.io/s/vue-template-lni9w and then include it in the following html page:
|
@karol-f were you able to reproduce it with the above instructions? |
Sorry, not yet, I still have it on my list. |
Ok, no worries. Let me know if you need more information. |
@karol-f I just noticed the status of this issue is still "waiting for feedback". Maybe you can change this to "investigating" or something like that? |
@karol-f Hey Karol, thank you so much for your work! Any update on the slot issue? |
I have taken the following workarounds. // before
Vue.customElement('slot-component', slotComponent);
// after
import { getProps } from 'vue-custom-element/src/utils/props'
const asyncComponentDefinition = (component) => () => new Promise((resolve) => {
setTimeout(() => {
resolve(component)
}, 0)
})
Vue.customElement('slot-component', asyncComponentDefinition(slotComponent), {
props: getProps(slotComponent).camelCase
}); |
Wow, awesome to see this community active! |
@aki77 you are awesome!! HelloWorld.vue this will go into
XButton.vue. this has
custom-element-build.js. this uses @Kai77 method
command
html
|
@aki77 can you explain how your code work? |
In Chrome, the child elements does not seem to be present yet at the time of the connectedCallback event.
|
Thanks @aki77 |
Like this? https://karol-f.github.io/vue-custom-element/#/demos/lazy-loading |
Is there a solution for the slots issue on Chrome that doesn't involve delaying component styles loading? |
I created a Vue component "simple-form" for building dynamic forms. It's using vue-custom-element in order to be able to inject it in my websites.
To be able to specify a custom header, footer and other stuff for each form, I'm defining several slots in the components template.
Basically, the template looks something like this:
Everything works fine, except that in Chrome and Opera the slots are not correctly injected.
This is how I use the component in my website:
For debugging purposes I'm using the startmsg and endmsg slots in 2 ways: as a template tag (1) and as a named slot (2)
In the attached screenshot you can see that the startmsg is not injected inside the div tag with id="startmsg".
Instead, all slots are injected at the end of the component, right before the closing tag
Moreover, when using a template tag (1) the slot content is inserted inside a "#document-fragment", which is not visible in the browser.
Any ideas what's happening here?
The text was updated successfully, but these errors were encountered: