forked from sveltejs/svelte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass hoisted values through to slots (sveltejs#3124)
* Fixed bug with slot props variables * dont add hoisted items to context * alternative fix for sveltejs#2586 * update slots more conservatively
- Loading branch information
1 parent
6af23ba
commit b2d9da3
Showing
7 changed files
with
71 additions
and
15 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
10 changes: 10 additions & 0 deletions
10
src/compiler/compile/render_dom/wrappers/shared/is_dynamic.ts
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,10 @@ | ||
import { Var } from '../../../../interfaces'; | ||
|
||
export default function is_dynamic(variable: Var) { | ||
if (variable) { | ||
if (variable.mutated || variable.reassigned) return true; // dynamic internal state | ||
if (!variable.module && variable.writable && variable.export_name) return true; // writable props | ||
} | ||
|
||
return false; | ||
} |
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 @@ | ||
<script> | ||
let fooText = 'foo'; | ||
</script> | ||
|
||
<div> | ||
<slot someText={fooText}></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,20 @@ | ||
export default { | ||
html: ` | ||
<div> | ||
<p>foo</p> | ||
</div> | ||
`, | ||
|
||
async test({ assert, target, window }) { | ||
const div = target.querySelector('div'); | ||
const click = new window.MouseEvent('click'); | ||
|
||
await div.dispatchEvent(click); | ||
|
||
assert.htmlEqual(target.innerHTML, ` | ||
<div> | ||
<p>foo</p> | ||
</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,7 @@ | ||
<script> | ||
import Nested from './Nested.svelte'; | ||
</script> | ||
|
||
<Nested let:someText={someText}> | ||
<p>{someText}</p> | ||
</Nested> |