mirror of https://github.com/sveltejs/svelte
feat: add has function to createContext (#18472)
closes #18471. --------- Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>pull/18733/head
parent
5034b59e9e
commit
4ae5eb3f23
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
feat: add `has` function to `createContext`
|
||||||
@ -1,7 +1,13 @@
|
|||||||
<script>
|
<script>
|
||||||
import { get } from './main.svelte';
|
import { get, has, has_unset } from './main.svelte';
|
||||||
|
|
||||||
const message = get();
|
const message = get();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<h1>{message}</h1>
|
<h1>{message}</h1>
|
||||||
|
{#if has()}
|
||||||
|
<h2>it's me</h2>
|
||||||
|
{/if}
|
||||||
|
{#if !has_unset()}
|
||||||
|
<h2>or not</h2>
|
||||||
|
{/if}
|
||||||
|
|||||||
@ -1,7 +1,13 @@
|
|||||||
<script>
|
<script>
|
||||||
import { get } from './main.svelte';
|
import { get, has, has_unset } from './main.svelte';
|
||||||
|
|
||||||
const message = get();
|
const message = get();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<h1>{message}</h1>
|
<h1>{message}</h1>
|
||||||
|
{#if has()}
|
||||||
|
<h2>it's me</h2>
|
||||||
|
{/if}
|
||||||
|
{#if !has_unset()}
|
||||||
|
<h2>or not</h2>
|
||||||
|
{/if}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { test } from '../../test';
|
import { test } from '../../test';
|
||||||
|
|
||||||
export default test({
|
export default test({
|
||||||
html: `<h1>hello</h1>`
|
html: `<h1>hello</h1><h2>it's me</h2><h2>or not</h2>`
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in new issue