Skip to content

Ability to define slots as <template>'s with proper DOM hydration #4370

@campbeln

Description

@campbeln

Not all DOM elements can exist outside of specified parent elements. For example, a <tbody> cannot exist outside of a <table> nor an <option> or <optgroup> outside of a <select>. However, these nesting-required DOM elements can be defined under a <template> as it's contents are not parsed.

It would be nice to be able to define a slot source as <template slot="slotName"/> and have it's (unparsed) innerHTML properly hydrated (see an in-depth discussion here). Conversely, the ability to have <table><tbody slot="slotName"></tbody></table> definitions would be required, or another solution would have to be worked out to properly target the slot's destination without breaking the DOM (as a <slot> is not valid under a <table>, or is this different in the world of webcontrols?).

The end result of this feature would be the ability to define complex <table> structures as well as <option>s`s under `s using handlebar'ed HTML, removing the need for verbose object definitions to set individual classes/values/content/etc. A possible alternative to this would be to create a hook that allows for developer code to handle the slot HTML insertion, whereby allowing the developer to target the required elements and properly hydrate the DOM as required prior to (re)binding. This would be a nice feature in it's own right, but would add to Svelte's API which may not be a desired result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions