-
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
Changes from 4 commits
cbe6460
c166486
7460711
721e063
572884c
66efe27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<x-dangling-container> | ||
<x-slot> | ||
<x-leaf> | ||
<!----> | ||
<x-component slot="dangling"> | ||
Component content | ||
</x-component> | ||
<!----> | ||
<!----> | ||
<x-component> | ||
Component content | ||
</x-component> | ||
<!----> | ||
</x-leaf> | ||
</x-slot> | ||
</x-dangling-container> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const tagName = 'x-dangling-container'; | ||
export { default } from 'x/container'; | ||
export * from 'x/container'; | ||
export const features = []; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template lwc:render-mode="light"> | ||
Component content | ||
</template> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { LightningElement } from 'lwc'; | ||
|
||
export default class extends LightningElement { | ||
static renderMode = 'light'; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<template lwc:render-mode="light"> | ||
<x-slot> | ||
<x-component slot="top"></x-component> | ||
<x-component slot="bottom"></x-component> | ||
</x-slot> | ||
</template> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { LightningElement } from 'lwc'; | ||
|
||
export default class extends LightningElement { | ||
static renderMode = 'light'; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<template lwc:render-mode="light"> | ||
<slot name="leafTop" slot="dangling"></slot> | ||
<slot name="leafBottom"></slot> | ||
</template> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { LightningElement } from 'lwc'; | ||
|
||
export default class extends LightningElement { | ||
static renderMode = 'light'; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<template lwc:render-mode="light"> | ||
<x-leaf> | ||
<slot name="top" slot="leafTop"></slot> | ||
<slot name="bottom" slot="leafBottom"></slot> | ||
</x-leaf> | ||
</template> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { LightningElement } from 'lwc'; | ||
|
||
export default class extends LightningElement { | ||
static renderMode = 'light'; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<template lwc:render-mode="light"> | ||
<x-slot> | ||
<h1 slot="top">top content</h1> | ||
<h1 slot="bottom">bottom content</h1> | ||
<h2 slot="bottom">bottom content</h2> | ||
</x-slot> | ||
</template> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<template lwc:render-mode="light"> | ||
<slot name="top" slot="bottom"></slot> | ||
<slot name="bottom"></slot> | ||
<slot name="leafTop" slot="dangling"></slot> | ||
<slot name="leafBottom"></slot> | ||
</template> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<template lwc:render-mode="light"> | ||
<x-leaf> | ||
<slot name="top" slot="bottom"></slot> | ||
<slot name="bottom" slot="top"></slot> | ||
<slot name="top" slot="leafTop"></slot> | ||
<slot name="bottom" slot="leafBottom"></slot> | ||
</x-leaf> | ||
</template> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,9 @@ const bExportTemplate = esTemplate` | |
let textContentBuffer = ''; | ||
let didBufferTextContent = false; | ||
|
||
// This will get overridden but requires initialization. | ||
const slotAttributeValue = null; | ||
Comment on lines
+35
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does it get overridden if it's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. { } |
||
|
||
// Establishes a contextual relationship between two components for ContextProviders. | ||
// This variable will typically get overridden (shadowed) within slotted content. | ||
const contextfulParent = instance; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. |
||
See: engine-server/src/__tests__/fixtures/slot-forwarding/slots/dangling/ for example case. | ||
*/ | ||
if (slotAttributeValue) { | ||
childAttrs.slot = slotAttributeValue; | ||
} | ||
${ | ||
/* | ||
Slotted content is inserted here. | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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 commentThe 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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, much clearer |
||||||
See: engine-server/src/__tests__/fixtures/slot-forwarding/slots/dangling/ for example case. | ||||||
*/ | ||||||
if (slotAttributeValue) { | ||||||
childAttrs.slot = slotAttributeValue; | ||||||
} | ||||||
${ | ||||||
/* | ||||||
Slotted content is inserted 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.
Is that right?