-
Notifications
You must be signed in to change notification settings - Fork 784
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(runtime): slot name forwarding & attribute reset (#4993)
* always update slot attributes when relocating * add test case * darn apostrophe Co-authored-by: Ryan Waskiewicz <ryanwaskiewicz@gmail.com> * remove slot ref check --------- Co-authored-by: Ryan Waskiewicz <ryanwaskiewicz@gmail.com>
- Loading branch information
1 parent
4959295
commit ee60f3b
Showing
7 changed files
with
138 additions
and
24 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
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,17 @@ | ||
import { Component, h, Host, Prop } from '@stencil/core'; | ||
|
||
@Component({ | ||
tag: 'slot-nested-name-change-child', | ||
}) | ||
export class SlotNestedNameChangeChild { | ||
@Prop() state: boolean; | ||
|
||
render() { | ||
return ( | ||
<Host> | ||
<div>State: {this.state.toString()}</div> | ||
<slot name="default" /> | ||
</Host> | ||
); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
test/karma/test-app/slot-nested-name-change/cmp-parent.tsx
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 { Component, h, Host } from '@stencil/core'; | ||
|
||
@Component({ | ||
tag: 'slot-nested-name-change', | ||
}) | ||
export class SlotNestedNameChange { | ||
render() { | ||
return ( | ||
<Host> | ||
<div> | ||
<slot-nested-name-change-child state={true}> | ||
<slot slot="default" /> | ||
</slot-nested-name-change-child> | ||
</div> | ||
</Host> | ||
); | ||
} | ||
} |
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 @@ | ||
<!doctype html> | ||
<meta charset="utf8" /> | ||
<script src="./build/testapp.esm.js" type="module"></script> | ||
<script src="./build/testapp.js" nomodule></script> | ||
|
||
<slot-nested-name-change> | ||
<p>Hello</p> | ||
</slot-nested-name-change> |
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,32 @@ | ||
import { setupDomTests } from '../util'; | ||
|
||
describe('slot-nested-name-change', function () { | ||
const { setupDom, tearDownDom } = setupDomTests(document); | ||
let app: HTMLElement | undefined; | ||
let host: HTMLElement | undefined; | ||
|
||
beforeEach(async () => { | ||
app = await setupDom('/slot-nested-name-change/index.html'); | ||
host = app.querySelector('slot-nested-name-change'); | ||
}); | ||
|
||
afterEach(tearDownDom); | ||
|
||
it('should render', () => { | ||
expect(host).toBeDefined(); | ||
}); | ||
|
||
it('should correctly render the slot content', () => { | ||
const childCmp = host.querySelector('slot-nested-name-change-child'); | ||
|
||
expect(childCmp.children.length).toBe(2); | ||
|
||
const firstChild = childCmp.children[0]; | ||
expect(firstChild.tagName).toBe('DIV'); | ||
expect(firstChild.textContent.trim()).toBe('State: true'); | ||
|
||
const secondChild = childCmp.children[1]; | ||
expect(secondChild.tagName).toBe('P'); | ||
expect(secondChild.textContent.trim()).toBe('Hello'); | ||
}); | ||
}); |