Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtual DOM bug: <slot /> array on second render #1997

Closed
petermikitsh opened this issue Nov 7, 2019 · 3 comments
Closed

Virtual DOM bug: <slot /> array on second render #1997

petermikitsh opened this issue Nov 7, 2019 · 3 comments

Comments

@petermikitsh
Copy link
Contributor

Stencil version:

 @stencil/core@1.7.5

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:

When rendering an array into a <slot />, during the initial render, array items are added at the correct location in the DOM.

On a second render, a new array element is rendered as a child of the parent's parent.

<my-select class="hydrated">
  <!---->
  <select>
    <option value="foo">foo</option>
  </select>
  <option value="bar">bar</option>
</my-select>

Expected behavior:

On the second render, the new array element is a DOM sibling to other array elements.

<my-select class="hydrated">
  <!---->
  <select>
    <option value="foo">foo</option>
    <option value="bar">bar</option>
  </select>
</my-select>

Steps to reproduce:

Repro link: https://github.com/petermikitsh/stencil-vdom-bug

Related code:

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

@Component({
  tag: "my-component",
  styleUrl: "my-component.css",
  shadow: true
})
export class MyComponent {
  connectedCallback() {
    window.setTimeout(() => {
      this.options = ["foo", "bar"];
    }, 4000);
  }

  @State() options = ["foo"];

  render() {
    return (
      <div>
        <div>
          <my-select>
            {this.options.map(opt => (
              <option key={opt} value={opt}>
                {opt}
              </option>
            ))}
          </my-select>
        </div>
      </div>
    );
  }
}
import { Component, h } from "@stencil/core";

@Component({
  tag: "my-select",
  shadow: false
})
export class MySelect {
  render() {
    return (
      <select>
        <slot />
      </select>
    );
  }
}
@dutscher
Copy link
Contributor

it seems tobe related to #1968
cheers

@zurfluh
Copy link

zurfluh commented Oct 21, 2021

I just encountered this issue too. It would be nice to have the fix merged soon. 🙏

@splitinfinities
Copy link
Contributor

Please signal boost @johnjenkins' PR please! Reactions there will be the source of truth for which of the many PR's out that we will take on next.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants