-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: repro light dom slot forwarding bug
- Loading branch information
1 parent
fd3c9e6
commit 5035243
Showing
13 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
packages/@lwc/integration-karma/test/light-dom/slot-fowarding/slots/duplicates/index.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { createElement } from 'lwc'; | ||
import LightContainer from 'light/container'; | ||
import ShadowContainer from 'shadow/container'; | ||
|
||
const scenarios = [ | ||
{ | ||
name: 'light', | ||
tagName: 'light-container', | ||
Ctor: LightContainer, | ||
}, | ||
{ | ||
name: 'shadow', | ||
tagName: 'shadow-container', | ||
Ctor: ShadowContainer, | ||
}, | ||
]; | ||
|
||
scenarios.forEach(({ name, tagName, Ctor }) => { | ||
describe(name, () => { | ||
// The bug is originally in light DOM, but the shadow DOM tests are just to demonstrate | ||
// that the same LWC templates work correctly in shadow DOM mode. | ||
it('issue #4446 - duplicate named slots with slot forwarding and reactivity', async () => { | ||
const elm = createElement(tagName, { is: Ctor }); | ||
|
||
document.body.appendChild(elm); | ||
|
||
// step 1 - initial render with isTablet=false | ||
await Promise.resolve(); | ||
|
||
let header, menu, span; | ||
|
||
const assertExpectedHtml = () => { | ||
const root = elm.shadowRoot || elm; | ||
header = root.querySelector('light-header,shadow-header'); | ||
menu = root.querySelector('light-menu,shadow-menu'); | ||
span = root.querySelector('span'); | ||
|
||
expect(header).not.toBeNull(); | ||
expect(menu).not.toBeNull(); | ||
expect(span).not.toBeNull(); | ||
expect(span.textContent).toBe('Hello'); | ||
}; | ||
|
||
assertExpectedHtml(); | ||
|
||
// step 2 - change child property without going through the parent | ||
header.isTablet = true; | ||
await Promise.resolve(); | ||
|
||
assertExpectedHtml(); | ||
|
||
// step 3 - toggle back to original state | ||
header.isTablet = false; | ||
await Promise.resolve(); | ||
|
||
assertExpectedHtml(); | ||
}); | ||
}); | ||
}); |
7 changes: 7 additions & 0 deletions
7
...ation-karma/test/light-dom/slot-fowarding/slots/duplicates/light/container/container.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<template lwc:render-mode="light"> | ||
<light-header> | ||
<light-menu slot="navigation"> | ||
<span slot="mobile">Hello</span> | ||
</light-menu> | ||
</light-header> | ||
</template> |
5 changes: 5 additions & 0 deletions
5
...gration-karma/test/light-dom/slot-fowarding/slots/duplicates/light/container/container.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
} |
8 changes: 8 additions & 0 deletions
8
...integration-karma/test/light-dom/slot-fowarding/slots/duplicates/light/header/header.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<template lwc:render-mode="light"> | ||
<div lwc:if={isTablet}> | ||
<slot name="navigation"></slot> | ||
</div> | ||
<div lwc:else> | ||
<slot name="navigation"></slot> | ||
</div> | ||
</template> |
7 changes: 7 additions & 0 deletions
7
...c/integration-karma/test/light-dom/slot-fowarding/slots/duplicates/light/header/header.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { LightningElement, api } from 'lwc'; | ||
|
||
export default class extends LightningElement { | ||
static renderMode = 'light'; | ||
|
||
@api isTablet = false; | ||
} |
3 changes: 3 additions & 0 deletions
3
...lwc/integration-karma/test/light-dom/slot-fowarding/slots/duplicates/light/menu/menu.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template lwc:render-mode="light"> | ||
<slot name="mobile"></slot> | ||
</template> |
5 changes: 5 additions & 0 deletions
5
.../@lwc/integration-karma/test/light-dom/slot-fowarding/slots/duplicates/light/menu/menu.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
} |
7 changes: 7 additions & 0 deletions
7
...tion-karma/test/light-dom/slot-fowarding/slots/duplicates/shadow/container/container.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<template lwc:render-mode="shadow"> | ||
<shadow-header> | ||
<shadow-menu slot="navigation"> | ||
<span slot="mobile">Hello</span> | ||
</shadow-menu> | ||
</shadow-header> | ||
</template> |
5 changes: 5 additions & 0 deletions
5
...ration-karma/test/light-dom/slot-fowarding/slots/duplicates/shadow/container/container.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = 'shadow'; | ||
} |
8 changes: 8 additions & 0 deletions
8
...ntegration-karma/test/light-dom/slot-fowarding/slots/duplicates/shadow/header/header.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<template lwc:render-mode="shadow"> | ||
<div lwc:if={isTablet}> | ||
<slot name="navigation"></slot> | ||
</div> | ||
<div lwc:else> | ||
<slot name="navigation"></slot> | ||
</div> | ||
</template> |
7 changes: 7 additions & 0 deletions
7
.../integration-karma/test/light-dom/slot-fowarding/slots/duplicates/shadow/header/header.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { LightningElement, api } from 'lwc'; | ||
|
||
export default class extends LightningElement { | ||
static renderMode = 'shadow'; | ||
|
||
@api isTablet = false; | ||
} |
3 changes: 3 additions & 0 deletions
3
...wc/integration-karma/test/light-dom/slot-fowarding/slots/duplicates/shadow/menu/menu.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template lwc:render-mode="shadow"> | ||
<slot name="mobile"></slot> | ||
</template> |
5 changes: 5 additions & 0 deletions
5
...@lwc/integration-karma/test/light-dom/slot-fowarding/slots/duplicates/shadow/menu/menu.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = 'shadow'; | ||
} |