You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Components are not able to prevent child elements from being rendered.
For example:
classMyComponent{
@State()hidden: boolean;render(){if(this.hidden)return;return(<div>
Some content
<slot/></div>);}}// Component usagereturn<my-component>Child Content</my-component>;
When the component is initially rendered it behaves as expected.
If the hidden state is set on the component then the component content does not render but the child elements (in this case "Child Content") still render.
Expected behavior:
It should be possible for a component to prevent child elements from being rendered.
It appears that Stencil is trying to provide default <slot /> behavior even if the component does not specify a slot.
Some possible approaches:
If the render method returns null or undefined then do not render child elements. This would not handle the potential use case where the component want to render some content but omit child elements.
Only include child elements if an explicit <slot> is rendered by the component. In general it seems risky to have default slot behavior when the component does not indicate a location for the content but maybe there are use cases for this feature.
The text was updated successfully, but these errors were encountered:
Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Stencil, please create a new issue and ensure the template is fully filled out.
Stencil version:
I'm submitting a:
[x] bug report
Current behavior:
Components are not able to prevent child elements from being rendered.
For example:
When the component is initially rendered it behaves as expected.
If the
hidden
state is set on the component then the component content does not render but the child elements (in this case "Child Content") still render.Expected behavior:
It should be possible for a component to prevent child elements from being rendered.
It appears that Stencil is trying to provide default
<slot />
behavior even if the component does not specify a slot.Some possible approaches:
<slot>
is rendered by the component. In general it seems risky to have default slot behavior when the component does not indicate a location for the content but maybe there are use cases for this feature.The text was updated successfully, but these errors were encountered: