-
Notifications
You must be signed in to change notification settings - Fork 766
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(slot-fallback): fix hiding fallback slot content issue when the s…
…lotted element is a text node (#5496) * fix(slot-fallback): fix hiding fallback slot content issue when the slotted element is a text node * test: fix test related reviews * test: fix test related reviews * Update test/wdio/slot-fallback-with-textnode/cmp.test.tsx --------- Co-authored-by: Christian Bromann <git@bromann.dev>
- Loading branch information
1 parent
20f74fc
commit 29c69c4
Showing
4 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
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
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,16 @@ | ||
import { Component, h } from '@stencil/core'; | ||
|
||
@Component({ | ||
tag: 'cmp-avatar', | ||
shadow: false, | ||
scoped: true, | ||
}) | ||
export class CmpAvatar { | ||
render() { | ||
return ( | ||
<div class="container"> | ||
<slot>DEFAULT</slot> | ||
</div> | ||
); | ||
} | ||
} |
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,18 @@ | ||
import { h } from '@stencil/core'; | ||
import { render } from '@wdio/browser-runner/stencil'; | ||
|
||
describe('slot-fallback-with-textnode', function () { | ||
beforeEach(() => { | ||
render({ | ||
template: () => <my-component></my-component>, | ||
}); | ||
}); | ||
|
||
it('should hide fallback content when provided slot is text node', async () => { | ||
await expect($('.container')).toHaveText('DEFAULT', { trim: true }); | ||
await $('#toggle-button').click(); | ||
|
||
await expect($('.container')).not.toHaveText('DEFAULT', { trim: true }); | ||
await expect($('.container')).toHaveText('JD', { trim: true }); | ||
}); | ||
}); |
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,21 @@ | ||
import { Component, Fragment, h, State } from '@stencil/core'; | ||
|
||
@Component({ | ||
tag: 'my-component', | ||
shadow: false, | ||
scoped: true, | ||
}) | ||
export class MyComponent { | ||
@State() shortName: null | string; | ||
|
||
render() { | ||
return ( | ||
<Fragment> | ||
<cmp-avatar>{this.shortName}</cmp-avatar> | ||
<button id="toggle-button" onClick={() => (this.shortName = this.shortName ? null : 'JD')}> | ||
Toggle ShortName | ||
</button> | ||
</Fragment> | ||
); | ||
} | ||
} |