question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Any workaround for `slot` attribute name?

See original GitHub issue

I’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:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
karol-fcommented, Jul 21, 2017

Unfortunately when vue-custom-element gets DOM, Custom Element is already initialized and all slots 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. Regards

1reaction
trusktrcommented, Jan 3, 2018

Here’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 what rendererCallback 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found