Any workaround for `slot` attribute name?
See original GitHub issueI’m trying to migrate a native web component over to vue-custom-element. It’s in use in production already, with components using the slot
attribute in order to organize the layout.
Is there any workaround at the moment to allow vue-custom-element to replace these components without updating the slot
attribute? Possibly rewrite the attributes using JS before the component loads?
Anyone have any experience with this? I can hack at it and try to get something working, but any pointers would be greatly appreciated.
Thanks!
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
The Web Component Slot element - HTML - MDN Web Docs
Attributes. This element includes the global attributes. name. The slot's name. A named slot is a <slot> element with a name attribute.
Read more >HTML slot Attribute - GeeksforGeeks
name : It defines the name of a particular slot in the shadow tree. It should be unique. Class: To access the particular...
Read more >Error using multiple dynamic slot names (Invalid ... - GitHub
Multiple dynamic slot names should work as expected. What is actually happening? The following error is thrown: Invalid dynamic argument ...
Read more >css - How do I select all slotted by name? - Stack Overflow
How do I select all slotted by name? · 1. [slot="thing"]{ border: 2px dashed #f00; } Attribute selectors · So would thing be...
Read more >vue/v-slot-style
The --fix option on the command line can automatically fix some of the problems ... The style for named slots (E.g. <template #named="">...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Unfortunately when
vue-custom-element
gets DOM, Custom Element is already initialized and allslots
are gone from DOM. So I don’t think that we can easily pass slots HTML to Vue (please, please correct me if I’m wrong).You can read about slots here - https://developers.google.com/web/fundamentals/getting-started/primers/shadowdom#composition-and-slots
EDIT maybe we can just parse vue component passed to
vue-custom-element
in search of slots (we already do that) and insert<slot>
and<slot name="xyz">
before Vue init. This seems doable. I’ll try to play with it in next days. RegardsHere’s how SkateJS allows use of ShadowDOM slots with Vue rendering: https://github.com/skatejs/skatejs/issues/1220
If you see the linked gist there, it hides the slot element inside a
<real-slot>
Vue component. You may have to get familiar with whatrendererCallback
is in SkateJS to understand what it is doing.rendererCallback
allows a Web Component author to define how the element renders (f.e. it can render with React, Vue, Angular, etc).It might be possible to achieve a similar sort of thing here, using a Vue component proxy like SkateJS did with the
<real-slot>
Vue component.