-
Notifications
You must be signed in to change notification settings - Fork 401
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
fix forwarded dangling slots #5164
Conversation
// This will get overridden but requires initialization. | ||
const slotAttributeValue = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does it get overridden if it's const
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ }
@@ -19,6 +19,13 @@ const bYieldFromChildGenerator = esTemplateWithYield` | |||
{ | |||
const childProps = ${/* child props */ is.objectExpression}; | |||
const childAttrs = ${/* child attrs */ is.objectExpression}; | |||
/* | |||
If a slotAttributeValue is present, it is dangling and should be assigned to any slotted content. This behavior aligns with v1 and engine-dom. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify what "dangling" means here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -25,6 +25,13 @@ const bYieldFromDynamicComponentConstructorGenerator = esTemplateWithYield` | |||
} | |||
const childProps = ${/* child props */ is.objectExpression}; | |||
const childAttrs = ${/* child attrs */ is.objectExpression}; | |||
/* | |||
If a slotAttributeValue is present, it is dangling and should be assigned to any slotted content. This behavior aligns with v1 and engine-dom. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify what "dangling" means here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A slot that is referenced but does not exist (see example fixture on the line below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add that to the code comment 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a slotAttributeValue is present, it is dangling and should be assigned to any slotted content. This behavior aligns with v1 and engine-dom. | |
If `slotAttributeValue` is set, it references a slot that does not exist, and the `slot` attribute should be set in the DOM. This behavior aligns with engine-server and engine-dom. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, much clearer
@@ -263,6 +275,7 @@ export const Element: Transformer<IrElement | IrExternalComponent | IrSlot> = fu | |||
|
|||
return [ | |||
bYield(b.literal(`<${node.name}`)), | |||
...[bConditionallyYieldDanglingSlotName()], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...[bConditionallyYieldDanglingSlotName()], | |
bConditionallyYieldDanglingSlotName(), |
Creating and then spreading an array with one element is unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thx
const bConditionallyYieldDanglingSlotName = esTemplateWithYield` | ||
{ | ||
if (slotAttributeValue) { | ||
yield \` slot="\${slotAttributeValue}"\`; | ||
} | ||
} | ||
`<EsBlockStatement>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const bConditionallyYieldDanglingSlotName = esTemplateWithYield` | |
{ | |
if (slotAttributeValue) { | |
yield \` slot="\${slotAttributeValue}"\`; | |
} | |
} | |
`<EsBlockStatement>; | |
const bConditionallyYieldDanglingSlotName = esTemplateWithYield` | |
if (slotAttributeValue) { | |
yield \` slot="\${slotAttributeValue}"\`; | |
} | |
`<EsIfStatement>; |
We don't need to use a block statement wrapper here, because there's no new variables being declared.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, copy paste error
@@ -32,6 +32,9 @@ const bExportTemplate = esTemplate` | |||
let textContentBuffer = ''; | |||
let didBufferTextContent = false; | |||
|
|||
// This will get overridden but requires initialization. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// This will get overridden but requires initialization. | |
// This gets shadowed in slotted content generators, but needs to be initialized for top-level slots |
Is that right?
Details
Does this pull request introduce an observable change?
GUS work item
W-17587763