mirror of https://github.com/sveltejs/svelte
parent
c56653dfd6
commit
39e5aa0707
@ -0,0 +1,18 @@
|
||||
<svelte:options tag="custom-element"/>
|
||||
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
import { fade } from 'svelte/transition';
|
||||
|
||||
let show = false;
|
||||
|
||||
onMount(() => {
|
||||
show = true;
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if show}
|
||||
<p transition:fade>
|
||||
Fades in and out
|
||||
</p>
|
||||
{/if}
|
||||
@ -0,0 +1,18 @@
|
||||
import * as assert from 'assert';
|
||||
import './main.svelte';
|
||||
|
||||
export default async function (target) {
|
||||
target.innerHTML = '<custom-element></custom-element>';
|
||||
|
||||
// wait one tick in order for styles to be applied
|
||||
await Promise.resolve();
|
||||
|
||||
const el = target.querySelector('custom-element');
|
||||
const style = el.shadowRoot.querySelector('style');
|
||||
|
||||
assert.ok(style);
|
||||
assert.ok(style.sheet);
|
||||
assert.equal(style, el.shadowRoot.firstElementChild);
|
||||
assert.equal(style.sheet.cssRules.length, 1);
|
||||
assert.equal(el.shadowRoot.__svelte_stylesheet, style.sheet);
|
||||
}
|
||||
Loading…
Reference in new issue