Skip to content

Slot inside iteration or loop #2103

@Vinoth-LearningThings

Description

@Vinoth-LearningThings

Stencil version:

@stencil/core@1.8.1

I'm submitting a:

[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior:
Slot inside a loop works for the 1st iteration but not the following ones.

Expected behavior:
Slot inside a loop should work for all the iterations.

Steps to reproduce:

Below is my stencil component.

import { Component, h, State } from "@stencil/core";

@Component({
  tag: "list-body",
  styleUrl: "list-body.scss",
  shadow: false
})
export class Body {
  @State() data: Array<String> = ["James", "Carol"];

  render() {
    return (
      <div>
        <p>Teachers</p>
        {this.data.map(entry => {
          return (
            <div>
              <slot name="salutation"></slot>
              <span>{entry}</span>
            </div>
          );
        })}
      </div>
    );
  }
}
<list-body>
    <span slot="salutation">Prof.</span>
</list-body>

Expected Result:

<list-body class="hydrated">
    <!---->
    <div>
        <p>Teachers</p>
        <div><span slot="salutation">Prof.</span><span>James</span></div>
        <div><span slot="salutation">Prof.</span><span>Carol</span></div>
    </div>
</list-body>

Actual Result

<list-body class="hydrated">
    <!---->
    <div>
        <p>Teachers</p>
        <div><span slot="salutation">Prof.</span><span>James</span></div>
        <div><span>Carol</span></div>
    </div>
</list-body>

I am not clear if I am doing anything illogical. I really appreciate the help. Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    ionitron: stale issueThis issue has not seen any activity for a long period of time

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions