Skip to content

Using Slots shouldn't require template tags #7

@gone

Description

@gone

Consider the example from the documentation:

<x-panel>
  <!-- Named Slot -->
  <template slot="header">
    <h1>Panel Header</h1>
  </template>
  <!-- Default Slot -->
  <template>
    <p>Panel Content</p>
  </template>
</x-panel>

This could be more concisely expressed as:

<x-panel>
  <!-- Named Slot -->
    <h1 slot="header">Panel Header</h1>
  <!-- Default Slot -->
    <p>Panel Content</p>
</x-panel>

The Spec says:

Note: An unnamed <slot> will be filled with all of the custom element's top-level child nodes that do not have the slot attribute. This includes text nodes.

So this should probably work too:

<x-panel>
  <!-- Named Slot -->
    <h1 slot="header">Panel Header</h1>
  <!-- Default Slot -->
    <p>Panel Content</p>
    <p> some more content </p>
</x-panel>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions