mirror of https://github.com/sveltejs/svelte
Pass hoisted values through to slots (#3124)
* Fixed bug with slot props variables * dont add hoisted items to context * alternative fix for #2586 * update slots more conservativelypull/3139/head
parent
6af23ba88c
commit
b2d9da3460
@ -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;
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
<script>
|
||||
let fooText = 'foo';
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<slot someText={fooText}></slot>
|
||||
</div>
|
@ -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>
|
||||
`);
|
||||
}
|
||||
};
|
@ -0,0 +1,7 @@
|
||||
<script>
|
||||
import Nested from './Nested.svelte';
|
||||
</script>
|
||||
|
||||
<Nested let:someText={someText}>
|
||||
<p>{someText}</p>
|
||||
</Nested>
|
Loading…
Reference in new issue