-
Notifications
You must be signed in to change notification settings - Fork 770
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
Problem with hide fallback slot #2878
Comments
@adamdbradley @WickyNilliams |
fix advice: for (i = 0, ilen = childNodes.length; i < ilen; i++) {
childNode = childNodes[i];
if (childNode.nodeType === NODE_TYPE.ElementNode) {
if (childNode['s-sr']) {
// this is a slot fallback node
// get the slot name for this slot reference node
slotNameAttr = childNode['s-sn'];
// by default always show a fallback slot node
// then hide it if there are other slots in the light dom
childNode.hidden = false;
for (j = 0; j < ilen; j++) {
nodeType = childNodes[j].nodeType;
if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
// this sibling node is from a different component OR is a named fallback slot node
if (nodeType === NODE_TYPE.ElementNode && slotNameAttr === childNodes[j].getAttribute('slot')) {
childNode.hidden = true;
break;
}
} else {
// this is a default fallback slot node
// any element or text node (with content)
// should hide the default fallback slot node
if (
nodeType === NODE_TYPE.ElementNode ||
(nodeType === NODE_TYPE.TextNode && childNodes[j].textContent.trim() !== '')
) {
childNode.hidden = true;
break;
}
}
}
}
// keep drilling down
updateFallbackSlotVisibility(childNode);
}
} Add Slots the Light DOM Judgment: for (i = 0, ilen = childNodes.length; i < ilen; i++) {
childNode = childNodes[i];
// no update slots in the light dom
if (childNode.nodeType === NODE_TYPE.ElementNode && !childNode['s-ol']) {
if (childNode['s-sr']) {
// this is a slot fallback node
// get the slot name for this slot reference node
slotNameAttr = childNode['s-sn'];
// by default always show a fallback slot node
// then hide it if there are other slots in the light dom
childNode.hidden = false;
for (j = 0; j < ilen; j++) {
nodeType = childNodes[j].nodeType;
if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
// this sibling node is from a different component OR is a named fallback slot node
if (nodeType === NODE_TYPE.ElementNode && slotNameAttr === childNodes[j].getAttribute('slot')) {
childNode.hidden = true;
break;
}
} else {
// this is a default fallback slot node
// any element or text node (with content)
// should hide the default fallback slot node
if (
nodeType === NODE_TYPE.ElementNode ||
(nodeType === NODE_TYPE.TextNode && childNodes[j].textContent.trim() !== '')
) {
childNode.hidden = true;
break;
}
}
}
}
// keep drilling down
updateFallbackSlotVisibility(childNode);
}
} |
Hidden slot and hidden slot fallback should be processed centrally and not separately. |
When a Web component initializes the hidden slot tag, the component records $flags$of 4 because the external slot elements are processed only when the internal check reaches the slot tag, so the external slot elements are not hidden |
Is the problem solved? I see there is a PR that contains a fix for this issue. But I'm in |
This doesn't appear to be an issue in the latest version of Stencil (v4.9.1 at the time of this comment). Please let us know if you encounter this issue on the latest or future version(s). |
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:
Fallback slot messes between parent and child components
Expected behavior:
Correctly handle fallbak slot issues for parent and child components
Steps to reproduce:
Other information:
The text was updated successfully, but these errors were encountered: