Before Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 275 B After Width: | Height: | Size: 184 B |
Before Width: | Height: | Size: 229 B After Width: | Height: | Size: 168 B |
Before Width: | Height: | Size: 221 B After Width: | Height: | Size: 161 B |
Before Width: | Height: | Size: 405 B After Width: | Height: | Size: 320 B |
Before Width: | Height: | Size: 212 B After Width: | Height: | Size: 155 B |
Before Width: | Height: | Size: 213 B After Width: | Height: | Size: 155 B |
Before Width: | Height: | Size: 333 B After Width: | Height: | Size: 256 B |
Before Width: | Height: | Size: 411 B After Width: | Height: | Size: 315 B |
Before Width: | Height: | Size: 415 B After Width: | Height: | Size: 344 B |
Before Width: | Height: | Size: 356 B After Width: | Height: | Size: 258 B |
Before Width: | Height: | Size: 290 B After Width: | Height: | Size: 215 B |
Before Width: | Height: | Size: 320 B After Width: | Height: | Size: 260 B |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 280 B After Width: | Height: | Size: 221 B |
Before Width: | Height: | Size: 303 B After Width: | Height: | Size: 242 B |
Before Width: | Height: | Size: 260 B After Width: | Height: | Size: 200 B |
Before Width: | Height: | Size: 354 B After Width: | Height: | Size: 311 B |
Before Width: | Height: | Size: 334 B After Width: | Height: | Size: 280 B |
Before Width: | Height: | Size: 262 B After Width: | Height: | Size: 193 B |
Before Width: | Height: | Size: 292 B After Width: | Height: | Size: 239 B |
Before Width: | Height: | Size: 111 KiB After Width: | Height: | Size: 108 KiB |
@ -0,0 +1 @@
|
|||||||
|
<div>Hello world</div>
|
@ -0,0 +1,2 @@
|
|||||||
|
<main>This should be thrown away</main>
|
||||||
|
<div>hello</div>
|
@ -0,0 +1 @@
|
|||||||
|
export default {};
|
@ -0,0 +1 @@
|
|||||||
|
<div>Hello world</div>
|
@ -0,0 +1 @@
|
|||||||
|
<div>Hello world</div>
|
@ -0,0 +1 @@
|
|||||||
|
<main>This should be thrown away</main>
|
@ -0,0 +1 @@
|
|||||||
|
export default {};
|
@ -0,0 +1 @@
|
|||||||
|
<div>Hello world</div>
|
@ -0,0 +1,7 @@
|
|||||||
|
<script>
|
||||||
|
import { model } from "./store.svelte";
|
||||||
|
export let value = '';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<input bind:value={$model} />
|
||||||
|
{value}
|
@ -0,0 +1,7 @@
|
|||||||
|
<script>
|
||||||
|
import Inner from "./Inner.svelte";
|
||||||
|
export let defaultValue = '';
|
||||||
|
export let slotProps = '';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<slot {slotProps}><Inner value={defaultValue} /></slot>
|
@ -0,0 +1,39 @@
|
|||||||
|
export default {
|
||||||
|
html: `<input> <input> <input>`,
|
||||||
|
ssrHtml: `<input value="Blub"> <input value="Blub"> <input value="Blub">`,
|
||||||
|
|
||||||
|
async test({ assert, target, component, window }) {
|
||||||
|
const [input1, input2, inputFallback] = target.querySelectorAll("input");
|
||||||
|
|
||||||
|
assert.equal(component.getSubscriberCount(), 3);
|
||||||
|
|
||||||
|
input1.value = "a";
|
||||||
|
await input1.dispatchEvent(new window.Event("input"));
|
||||||
|
input1.value = "ab";
|
||||||
|
await input1.dispatchEvent(new window.Event("input"));
|
||||||
|
assert.equal(input1.value, "ab");
|
||||||
|
assert.equal(input2.value, "ab");
|
||||||
|
assert.equal(inputFallback.value, "ab");
|
||||||
|
|
||||||
|
component.props = "hello";
|
||||||
|
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<input> hello
|
||||||
|
<input> hello
|
||||||
|
<input>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
|
||||||
|
component.fallback = "world";
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<input> hello
|
||||||
|
<input> hello
|
||||||
|
<input> world
|
||||||
|
`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,23 @@
|
|||||||
|
<script>
|
||||||
|
import Outer from "./Outer.svelte";
|
||||||
|
import Inner from "./Inner.svelte";
|
||||||
|
import {model} from "./store.svelte";
|
||||||
|
|
||||||
|
export let props = '';
|
||||||
|
export let fallback = '';
|
||||||
|
|
||||||
|
export function getSubscriberCount() {
|
||||||
|
return model.getCount();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Outer slotProps={props} defaultValue={fallback} let:slotProps>
|
||||||
|
<Inner value={slotProps} />
|
||||||
|
</Outer>
|
||||||
|
|
||||||
|
<Outer slotProps={props} defaultValue={fallback} let:slotProps>
|
||||||
|
<Inner value={slotProps} />
|
||||||
|
</Outer>
|
||||||
|
|
||||||
|
<Outer slotProps={props} defaultValue={fallback}>
|
||||||
|
</Outer>
|
@ -0,0 +1,23 @@
|
|||||||
|
<script context="module">
|
||||||
|
let value = 'Blub';
|
||||||
|
let count = 0;
|
||||||
|
const subscribers = new Set();
|
||||||
|
export const model = {
|
||||||
|
subscribe(fn) {
|
||||||
|
subscribers.add(fn);
|
||||||
|
count ++;
|
||||||
|
fn(value);
|
||||||
|
return () => {
|
||||||
|
count--;
|
||||||
|
subscribers.delete(fn);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
set(v) {
|
||||||
|
value = v;
|
||||||
|
subscribers.forEach(fn => fn(v));
|
||||||
|
},
|
||||||
|
getCount() {
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
@ -0,0 +1 @@
|
|||||||
|
<slot name="slot2"></slot>
|
@ -0,0 +1,3 @@
|
|||||||
|
export default {
|
||||||
|
error: [`Element with a slot='...' attribute must be a child of a component or a descendant of a custom element`]
|
||||||
|
};
|
@ -0,0 +1,11 @@
|
|||||||
|
<script>
|
||||||
|
import Nested from "./Nested.svelte";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Nested>
|
||||||
|
<div slot="slot1">
|
||||||
|
<div>
|
||||||
|
<div slot="slot2" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Nested>
|
@ -0,0 +1 @@
|
|||||||
|
<slot name="slot2"></slot>
|
@ -0,0 +1,3 @@
|
|||||||
|
export default {
|
||||||
|
error: [`Element with a slot='...' attribute must be a child of a component or a descendant of a custom element`]
|
||||||
|
};
|
@ -0,0 +1,11 @@
|
|||||||
|
<script>
|
||||||
|
import Nested from "./Nested.svelte";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Nested>
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
<div slot="slot2" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Nested>
|
@ -0,0 +1 @@
|
|||||||
|
<slot name="slot2"></slot>
|
@ -0,0 +1,3 @@
|
|||||||
|
export default {
|
||||||
|
error: [`Element with a slot='...' attribute must be a child of a component or a descendant of a custom element`]
|
||||||
|
};
|
@ -0,0 +1,9 @@
|
|||||||
|
<script>
|
||||||
|
import Nested from "./Nested.svelte";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Nested>
|
||||||
|
<div slot="slot1">
|
||||||
|
<div slot="slot2" />
|
||||||
|
</div>
|
||||||
|
</Nested>
|
@ -0,0 +1,37 @@
|
|||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
animals: ['alpaca', 'baboon', 'capybara'],
|
||||||
|
foo: 'something else'
|
||||||
|
},
|
||||||
|
|
||||||
|
html: `
|
||||||
|
before
|
||||||
|
<p>alpaca</p>
|
||||||
|
<p>baboon</p>
|
||||||
|
<p>capybara</p>
|
||||||
|
after
|
||||||
|
`,
|
||||||
|
|
||||||
|
test({ assert, component, target }) {
|
||||||
|
component.animals = [];
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
before
|
||||||
|
<p>no animals, but rather something else</p>
|
||||||
|
after
|
||||||
|
`);
|
||||||
|
|
||||||
|
component.foo = 'something other';
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
before
|
||||||
|
<p>no animals, but rather something other</p>
|
||||||
|
after
|
||||||
|
`);
|
||||||
|
|
||||||
|
component.animals = ['wombat'];
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
before
|
||||||
|
<p>wombat</p>
|
||||||
|
after
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,12 @@
|
|||||||
|
<script>
|
||||||
|
export let animals;
|
||||||
|
export let foo;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
before
|
||||||
|
{#each animals as animal (animal)}
|
||||||
|
<p>{animal}</p>
|
||||||
|
{:else}
|
||||||
|
<p>no animals, but rather {foo}</p>
|
||||||
|
{/each}
|
||||||
|
after
|
@ -0,0 +1,37 @@
|
|||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
animals: ['alpaca', 'baboon', 'capybara'],
|
||||||
|
foo: 'something else'
|
||||||
|
},
|
||||||
|
|
||||||
|
html: `
|
||||||
|
before
|
||||||
|
<p>alpaca</p>
|
||||||
|
<p>baboon</p>
|
||||||
|
<p>capybara</p>
|
||||||
|
after
|
||||||
|
`,
|
||||||
|
|
||||||
|
test({ assert, component, target }) {
|
||||||
|
component.animals = [];
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
before
|
||||||
|
<p>no animals, but rather something else</p>
|
||||||
|
after
|
||||||
|
`);
|
||||||
|
|
||||||
|
component.foo = 'something other';
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
before
|
||||||
|
<p>no animals, but rather something other</p>
|
||||||
|
after
|
||||||
|
`);
|
||||||
|
|
||||||
|
component.animals = ['wombat'];
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
before
|
||||||
|
<p>wombat</p>
|
||||||
|
after
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,12 @@
|
|||||||
|
<script>
|
||||||
|
export let animals;
|
||||||
|
export let foo;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
before
|
||||||
|
{#each animals as animal}
|
||||||
|
<p>{animal}</p>
|
||||||
|
{:else}
|
||||||
|
<p>no animals, but rather {foo}</p>
|
||||||
|
{/each}
|
||||||
|
after
|
@ -0,0 +1,7 @@
|
|||||||
|
<script>
|
||||||
|
export let count;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if count > 0}
|
||||||
|
<slot count={count-1}></slot>
|
||||||
|
{/if}
|
@ -0,0 +1,3 @@
|
|||||||
|
export default {
|
||||||
|
html: '5 4 3 2 1 0',
|
||||||
|
};
|
@ -0,0 +1,10 @@
|
|||||||
|
<script>
|
||||||
|
import Countdown from './Countdown.svelte';
|
||||||
|
export let count = 5;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{count}
|
||||||
|
|
||||||
|
<Countdown {count} let:count={i}>
|
||||||
|
<svelte:self count={i} />
|
||||||
|
</Countdown>
|
@ -0,0 +1,16 @@
|
|||||||
|
<script>
|
||||||
|
export let visible;
|
||||||
|
|
||||||
|
function foo() {
|
||||||
|
return {
|
||||||
|
duration: 100,
|
||||||
|
css: t => {
|
||||||
|
return `opacity: ${t}`;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if visible}
|
||||||
|
<div transition:foo></div>
|
||||||
|
{/if}
|
@ -0,0 +1,58 @@
|
|||||||
|
<script>
|
||||||
|
import { onMount, onDestroy, tick } from 'svelte';
|
||||||
|
|
||||||
|
export let component;
|
||||||
|
|
||||||
|
let frame;
|
||||||
|
let doc;
|
||||||
|
let content;
|
||||||
|
|
||||||
|
$: mountComponent(doc, component);
|
||||||
|
$: updateProps($$props);
|
||||||
|
|
||||||
|
function mountComponent(doc) {
|
||||||
|
if (content) content.$destroy();
|
||||||
|
if (doc && component) {
|
||||||
|
const { component, ...props } = $$props;
|
||||||
|
content = new component({ target: doc.body, props });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateProps(props) {
|
||||||
|
if (content) {
|
||||||
|
const { component, ...rest } = props;
|
||||||
|
content.$set(rest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadHandler() {
|
||||||
|
doc = frame.contentDocument;
|
||||||
|
// import styles
|
||||||
|
Array.from(document.querySelectorAll('style, link[rel="stylesheet"]'))
|
||||||
|
.forEach(node => doc.head.appendChild(node.cloneNode(true)));
|
||||||
|
}
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
await tick();
|
||||||
|
if (frame.contentDocument.readyState === 'complete' && frame.contentDocument.defaultView) {
|
||||||
|
loadHandler();
|
||||||
|
} else {
|
||||||
|
frame.addEventListener('load', loadHandler);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
onDestroy(() => {
|
||||||
|
if (frame) frame.removeEventListener('load', loadHandler);
|
||||||
|
if (content) content.$destroy();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<iframe bind:this={frame} title="frame"></iframe>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
iframe {
|
||||||
|
border: none;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
@ -0,0 +1,18 @@
|
|||||||
|
export default {
|
||||||
|
skip_if_ssr: true,
|
||||||
|
|
||||||
|
async test({ assert, component, target, window, raf }) {
|
||||||
|
const frame = target.querySelector('iframe');
|
||||||
|
await Promise.resolve();
|
||||||
|
|
||||||
|
component.visible = true;
|
||||||
|
const div = frame.contentDocument.querySelector('div');
|
||||||
|
|
||||||
|
raf.tick(25);
|
||||||
|
|
||||||
|
component.visible = false;
|
||||||
|
|
||||||
|
raf.tick(26);
|
||||||
|
assert.ok(~div.style.animation.indexOf('25ms'));
|
||||||
|
},
|
||||||
|
};
|
@ -0,0 +1,8 @@
|
|||||||
|
<script>
|
||||||
|
import Frame from './Frame.svelte';
|
||||||
|
import Foo from './Foo.svelte';
|
||||||
|
|
||||||
|
export let visible;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Frame component={Foo} {visible}/>
|
@ -0,0 +1 @@
|
|||||||
|
[]
|
@ -0,0 +1,7 @@
|
|||||||
|
<script>
|
||||||
|
const dummy = {
|
||||||
|
foo: 'bar'
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<input bind:value={dummy.foo}>
|
@ -0,0 +1,15 @@
|
|||||||
|
[{
|
||||||
|
"code": "invalid-binding",
|
||||||
|
"message": "Cannot bind to a variable which is not writable",
|
||||||
|
"pos": 61,
|
||||||
|
"start": {
|
||||||
|
"line": 5,
|
||||||
|
"column": 19,
|
||||||
|
"character": 61
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 5,
|
||||||
|
"column": 24,
|
||||||
|
"character": 66
|
||||||
|
}
|
||||||
|
}]
|
@ -0,0 +1,5 @@
|
|||||||
|
<script>
|
||||||
|
const dummy = 'foo';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<input bind:value={dummy}>
|
@ -0,0 +1,9 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"code": "invalid-slotted-content",
|
||||||
|
"message": "Element with a slot='...' attribute must be a child of a component or a descendant of a custom element",
|
||||||
|
"start": { "line": 10, "column": 9, "character": 138 },
|
||||||
|
"end": { "line": 10, "column": 19, "character": 148 },
|
||||||
|
"pos": 138
|
||||||
|
}
|
||||||
|
]
|
@ -0,0 +1,14 @@
|
|||||||
|
<script>
|
||||||
|
import Nested from './Nested.svelte';
|
||||||
|
let thing = false;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<custom-element>
|
||||||
|
<Nested>
|
||||||
|
{#if thing}
|
||||||
|
<div>
|
||||||
|
<div slot='bar' />
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</Nested>
|
||||||
|
</custom-element>
|
@ -0,0 +1 @@
|
|||||||
|
[]
|
@ -0,0 +1,15 @@
|
|||||||
|
<script>
|
||||||
|
import Nested from './Nested.svelte';
|
||||||
|
let thing = false;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Nested>
|
||||||
|
<custom-element>
|
||||||
|
<div>
|
||||||
|
<div slot='foo' />
|
||||||
|
</div>
|
||||||
|
{#if thing}
|
||||||
|
<div slot='bar' />
|
||||||
|
{/if}
|
||||||
|
</custom-element>
|
||||||
|
</Nested>
|