All files / components/ConditionalWrapper ConditionalWrapper.svelte

100% Statements 12/12
100% Branches 0/0
100% Functions 0/0
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 131x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
<script lang="ts">
  // Based on https://svelte.dev/repl/983851f4fb7044e8b5d66a53ca0b356b?version=3.48.0
  // When condition is met, wraps slot in the provided element.
  export let condition = false;
  export let tag = "div";
</script>
 
{#if condition && tag}
  <svelte:element this={tag} {...$$restProps}><slot /></svelte:element>
{:else}
  <slot />
{/if}