mirror of https://github.com/sveltejs/svelte
chore: add test to show usage of context in component template (#11061)
* chore: prevent usage of getContext during component template * repurpose test to be just a test to capture context in templatepull/11112/head
parent
e8f7437cf6
commit
ce348f0d69
@ -0,0 +1,7 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target }) {
|
||||
assert.htmlEqual(target.innerHTML, `hello world`);
|
||||
}
|
||||
});
|
@ -0,0 +1,11 @@
|
||||
<script>
|
||||
import { getContext, setContext } from 'svelte';
|
||||
|
||||
setContext('val', 'hello world')
|
||||
|
||||
const get_val = () => {
|
||||
return getContext('val');
|
||||
}
|
||||
</script>
|
||||
|
||||
{get_val()}
|
Loading…
Reference in new issue