Skip to content

Slot CRUD does not work properly when shadow is false #2877

Closed

Description

@chenyulun

Stencil version:

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 increase delete add update when shadow is false does not work properly

  1. When there is no slot inside Web Components, the user passes the slot to be present, but if shadow
    Is not displayed when true
@Component({
  tag: 'pui-example',
  shadow: false,
})
export class Example implements ComponentInterface {
render() {return (<Host></Host>)}
}

The wrong presentation flattened DOM:

<pui-example class="hydrated"><!----><div><span>outside default slot</span></div></pui-example>

Expected behavior flattened DOM

<pui-example class="hydrated"><!----><div hidden=""><span>outside default slot</span></div></pui-example>
  1. Initialize the hidden slot, pass it to the slot node when used, and display the slot inside the component with parameters that can correctly process the slot to its actual location. However, if the internal slot of the component is hidden here, the external slot node disappears and the external slot node should be moved back to its original position for hiding

  2. When you outsource an incoming slot and receive it internally, delete the outsourced slot. The hidden property of the internal slot-fb is not removed

When shadow is true, the browser will handle it just fine

Expected behavior:

Slot increase, delete and update when shadow is false will work normally

Steps to reproduce:

Related code:

import { Component, ComponentInterface, Prop, Host } from '@stencil/core';
@Component({
  tag: 'pui-example',
  shadow: false,
})
export class Example implements ComponentInterface {
  /**
   * Whether or not to show slot
  */
  @Prop() enabled = false;
  render(): VNode {
    return (
      <Host>
        {this.enabled && (
          <div data-txt="slot wrapper">
            <slot>
              <span>fallback default slot</span>
            </slot>
          </div>
        )}
      </Host>
    );
  }
}

DOM nodes to use and display:

// Use the code(Vue) showSlot = true
<pui-example>
  <div v-if="showSlot" data-txt="outside default slot">
    <span>outside default slot</span>
  </div>
</pui-example>
// flattened DOM: ====》Incoming slot should be hidden
<pui-example class="hydrated">
  <!---->
  <div data-txt="outside default slot">
    <span>outside default slot</span>
  </div>
</pui-example>

When the following statement is executed:

document.getElementsByTagName('pui-example')[0].enabled = true

This is normal as shown below

<pui-example class="hydrated"><!----><div data-txt="slot wrapper"><slot-fb hidden=""><span>fallback default slot</span></slot-fb><div data-txt="outside default slot"><span>outside default slot</span></div></div></pui-example>

When the following statement is executed:

document.getElementsByTagName('pui-example')[0].enabled = false

Incoming slot nodes are deleted: ====》It should be moved back to its original position and then hidden

<pui-example class="hydrated"><!----></pui-example>

Other information:

Activity

  1. added
    Resolution: Needs Investigation
    and removed on Mar 25, 2022
  2. added
    Resolution: Refine
    and removed
    Resolution: Needs Investigation
    on Sep 6, 2023
  3. added a commit that references this issue on Dec 6, 2023
    0c1f9f9
  4. added a commit that references this issue on Dec 6, 2023
    77bce27
  5. christian-bromann commented on Dec 11, 2023

    @christian-bromann
    Member

    A fix for this issue was released in v4.8.2. Thanks for reporting!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution: Refineslot-related

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions