mirror of https://github.com/sveltejs/svelte
update custom-elements tests update hydration tests update js tests update some tests update some tests update some tests update some tests update some tests update some tests update some tests update some tests update some tests update some tests update some tests update some tests update some tests update some tests update some tests update some testspull/1864/head
parent
2231a7eb19
commit
7f3cd0d655
@ -1,13 +1,11 @@
|
||||
<p>{foo}</p>
|
||||
<svelte:meta tag="custom-element"/>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
tag: 'custom-element',
|
||||
export function updateFoo(value) {
|
||||
foo = value;
|
||||
}
|
||||
|
||||
methods: {
|
||||
updateFoo(value) {
|
||||
this.foo = value;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
export let foo;
|
||||
</script>
|
||||
|
||||
<p>{foo}</p>
|
@ -1,13 +1,9 @@
|
||||
<svelte:meta tag="custom-element"/>
|
||||
|
||||
<span class='icon'></span>
|
||||
|
||||
<style>
|
||||
.icon::before {
|
||||
content: '\ff'
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
tag: 'custom-element'
|
||||
};
|
||||
</script>
|
||||
</style>
|
@ -1,7 +1,7 @@
|
||||
<h1>Hello {name}!</h1>
|
||||
<svelte:meta tag="custom-element"/>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
tag: 'custom-element'
|
||||
};
|
||||
</script>
|
||||
export let name;
|
||||
</script>
|
||||
|
||||
<h1>Hello {name}!</h1>
|
@ -1,13 +1,7 @@
|
||||
<button on:click='set({ count: count + 1 })'>count: {count}</button>
|
||||
<svelte:meta tag="my-counter"/>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
tag: 'my-counter',
|
||||
export let count = 0;
|
||||
</script>
|
||||
|
||||
data() {
|
||||
return {
|
||||
count: 0
|
||||
};
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<button on:click='{() => count += 1}'>count: {count}</button>
|
@ -1,12 +1,10 @@
|
||||
<Counter bind:count/>
|
||||
<p>clicked {count} times</p>
|
||||
<svelte:meta tag="my-app"/>
|
||||
|
||||
<script>
|
||||
import Counter from './Counter.html';
|
||||
|
||||
export default {
|
||||
tag: 'my-app',
|
||||
export let count;
|
||||
</script>
|
||||
|
||||
components: { Counter }
|
||||
};
|
||||
</script>
|
||||
<Counter bind:count/>
|
||||
<p>clicked {count} times</p>
|
@ -1,13 +1,9 @@
|
||||
<svelte:meta tag="custom-element"/>
|
||||
|
||||
<p>styled</p>
|
||||
|
||||
<style>
|
||||
p {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
tag: 'custom-element'
|
||||
};
|
||||
</script>
|
||||
</style>
|
@ -1,7 +1,7 @@
|
||||
<h1>Hello {name}!</h1>
|
||||
<svelte:meta tag="custom-element"/>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
tag: 'custom-element'
|
||||
};
|
||||
</script>
|
||||
export let name;
|
||||
</script>
|
||||
|
||||
<h1>Hello {name}!</h1>
|
@ -1,8 +1,9 @@
|
||||
<p>foo: {foo}</p>
|
||||
<p>bar: {bar}</p>
|
||||
<svelte:meta tag="my-app"/>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
tag: 'my-app'
|
||||
};
|
||||
</script>
|
||||
export let foo;
|
||||
export let bar;
|
||||
</script>
|
||||
|
||||
<p>foo: {foo}</p>
|
||||
<p>bar: {bar}</p>
|
@ -1,9 +1,12 @@
|
||||
<svelte:meta tag="my-app"/>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
tag: 'my-app',
|
||||
|
||||
oncreate() {
|
||||
this.wasCreated = true;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
import { onmount } from 'svelte';
|
||||
|
||||
export let wasCreated;
|
||||
|
||||
onmount(() => {
|
||||
wasCreated = true;
|
||||
});
|
||||
</script>
|
||||
|
||||
|
@ -1,15 +1,9 @@
|
||||
<my-widget class="foo" {items}/>
|
||||
<svelte:meta tag="custom-element"/>
|
||||
|
||||
<script>
|
||||
import './my-widget.html';
|
||||
|
||||
export default {
|
||||
tag: 'custom-element',
|
||||
export let items = ['a', 'b', 'c'];
|
||||
</script>
|
||||
|
||||
data() {
|
||||
return {
|
||||
items: ['a', 'b', 'c']
|
||||
};
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<my-widget class="foo" {items}/>
|
@ -1,14 +1,8 @@
|
||||
<p>{items.length} items</p>
|
||||
<p>{items.join(', ')}</p>
|
||||
<svelte:meta tag="my-widget"/>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
tag: 'my-widget',
|
||||
export let items = [];
|
||||
</script>
|
||||
|
||||
data() {
|
||||
return {
|
||||
items: []
|
||||
};
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<p>{items.length} items</p>
|
||||
<p>{items.join(', ')}</p>
|
@ -1,13 +1,7 @@
|
||||
<div>
|
||||
<Nested/>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
import Nested from './Nested.html';
|
||||
</script>
|
||||
|
||||
export default {
|
||||
components: {
|
||||
Nested
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<div>
|
||||
<Nested/>
|
||||
</div>
|
@ -1,11 +1,5 @@
|
||||
<Nested/>
|
||||
|
||||
<script>
|
||||
import Nested from './Nested.html';
|
||||
</script>
|
||||
|
||||
export default {
|
||||
components: {
|
||||
Nested
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<Nested/>
|
@ -1,4 +1,4 @@
|
||||
<button on:click='set({ clicked: true })'>click me</button>
|
||||
<button on:click='{() => clicked = true}'>click me</button>
|
||||
|
||||
{#if clicked}
|
||||
<p>clicked!</p>
|
||||
|
@ -1,23 +1,19 @@
|
||||
<a href="#" use:link>Test</a>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
actions: {
|
||||
link(node) {
|
||||
|
||||
function onClick(event) {
|
||||
event.preventDefault();
|
||||
history.pushState(null, null, event.target.href);
|
||||
}
|
||||
function link(node) {
|
||||
|
||||
function onClick(event) {
|
||||
event.preventDefault();
|
||||
history.pushState(null, null, event.target.href);
|
||||
}
|
||||
|
||||
node.addEventListener('click', onClick);
|
||||
node.addEventListener('click', onClick);
|
||||
|
||||
return {
|
||||
destroy() {
|
||||
node.removeEventListener('click', onClick);
|
||||
}
|
||||
}
|
||||
return {
|
||||
destroy() {
|
||||
node.removeEventListener('click', onClick);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<a href="#" use:link>Test</a>
|
@ -1,9 +1,5 @@
|
||||
<Nested foo={[1, 2, 3]}/>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
components: {
|
||||
Nested: window.Nested
|
||||
}
|
||||
};
|
||||
</script>
|
||||
const Nested = window.Nested;
|
||||
</script>
|
||||
|
||||
<Nested foo={[1, 2, 3]}/>
|
@ -1,10 +1,7 @@
|
||||
<Nested foo='bar'/>
|
||||
<svelte:meta immutable/>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
immutable: true,
|
||||
components: {
|
||||
Nested: window.Nested
|
||||
}
|
||||
};
|
||||
</script>
|
||||
const Nested = window.Nested;
|
||||
</script>
|
||||
|
||||
<Nested foo='bar'/>
|
@ -1,9 +1,5 @@
|
||||
<Nested foo='bar'/>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
components: {
|
||||
Nested: window.Nested
|
||||
}
|
||||
};
|
||||
</script>
|
||||
const Nested = window.Nested;
|
||||
</script>
|
||||
|
||||
<Nested foo='bar'/>
|
@ -1,9 +1,5 @@
|
||||
<Nested foo='bar'/>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
components: {
|
||||
Nested: window.Nested
|
||||
}
|
||||
};
|
||||
</script>
|
||||
const Nested = window.Nested;
|
||||
</script>
|
||||
|
||||
<Nested foo='bar'/>
|
@ -1,8 +1,11 @@
|
||||
<script>
|
||||
export default {
|
||||
computed: {
|
||||
a: ({ x }) => x * 2,
|
||||
b: ({ x }) => x * 3
|
||||
}
|
||||
};
|
||||
export let x;
|
||||
|
||||
function a() {
|
||||
return x * 2;
|
||||
}
|
||||
|
||||
function b() {
|
||||
return x * 3;
|
||||
}
|
||||
</script>
|
@ -1,11 +1,9 @@
|
||||
<script>
|
||||
export default {
|
||||
data: () => ({
|
||||
foo: 'bar'
|
||||
}),
|
||||
import { onmount } from 'svelte';
|
||||
|
||||
oncreate() {
|
||||
alert(JSON.stringify(data()));
|
||||
}
|
||||
};
|
||||
export let foo = 'bar';
|
||||
|
||||
onmount(() => {
|
||||
alert(JSON.stringify(data()));
|
||||
});
|
||||
</script>
|
@ -1,12 +1,12 @@
|
||||
<script>
|
||||
export let foo;
|
||||
|
||||
function bar() {
|
||||
return foo * 2;
|
||||
}
|
||||
</script>
|
||||
|
||||
<p>
|
||||
{Math.max(0, foo)}
|
||||
{bar}
|
||||
</p>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
computed: {
|
||||
bar: ({ foo }) => foo * 2
|
||||
}
|
||||
};
|
||||
</script>
|
||||
{bar()}
|
||||
</p>
|
@ -1,2 +1,2 @@
|
||||
<div data-foo='bar'/>
|
||||
<div data-foo='{bar}'/>
|
||||
<div data-foo='{bar}'/>
|
@ -1,2 +1,2 @@
|
||||
<div data-foo='bar'/>
|
||||
<div data-foo='{bar}'/>
|
||||
<div data-foo='{bar}'/>
|
Before Width: | Height: | Size: 57 B After Width: | Height: | Size: 56 B |
@ -1,9 +1 @@
|
||||
<LazyLoad load="{() => import('./Foo.html')}"/>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
components: {
|
||||
LazyLoad
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<LazyLoad load="{() => import('./Foo.html')}"/>
|
@ -1,23 +1,21 @@
|
||||
{#each things as thing (thing.id)}
|
||||
<div animate:foo>{thing.name}</div>
|
||||
{/each}
|
||||
|
||||
<script>
|
||||
export default {
|
||||
animations: {
|
||||
foo(node, animation, params) {
|
||||
const dx = animation.from.left - animation.to.left;
|
||||
const dy = animation.from.top - animation.to.top;
|
||||
export let things;
|
||||
|
||||
function foo(node, animation, params) {
|
||||
const dx = animation.from.left - animation.to.left;
|
||||
const dy = animation.from.top - animation.to.top;
|
||||
|
||||
return {
|
||||
delay: params.delay,
|
||||
duration: 100,
|
||||
tick: (t, u) => {
|
||||
node.dx = u * dx;
|
||||
node.dy = u * dy;
|
||||
}
|
||||
};
|
||||
return {
|
||||
delay: params.delay,
|
||||
duration: 100,
|
||||
tick: (t, u) => {
|
||||
node.dx = u * dx;
|
||||
node.dy = u * dy;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
{#each things as thing (thing.id)}
|
||||
<div animate:foo>{thing.name}</div>
|
||||
{/each}
|
@ -1,16 +1,13 @@
|
||||
<button on:foo='foo( bar )'>foo</button>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
methods: {
|
||||
foo ( bar ) {
|
||||
console.log( bar );
|
||||
}
|
||||
},
|
||||
events: {
|
||||
foo ( node, callback ) {
|
||||
// code goes here
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
export let bar;
|
||||
|
||||
function handleFoo(bar) {
|
||||
console.log( bar );
|
||||
}
|
||||
|
||||
function foo(node, callback) {
|
||||
// code goes here
|
||||
}
|
||||
</script>
|
||||
|
||||
<button on:foo='{() => handleFoo( bar )}'>foo</button>
|
@ -1,19 +1,15 @@
|
||||
<div on:touchstart="handleTouchstart()">
|
||||
<button on:click|stopPropagation|preventDefault="handleClick()">click me</button>
|
||||
<button on:click|once|capture="handleClick()">or me</button>
|
||||
<button on:click|capture="handleClick()">or me!</button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
methods: {
|
||||
handleTouchstart() {
|
||||
// ...
|
||||
},
|
||||
function handleTouchstart() {
|
||||
// ...
|
||||
}
|
||||
|
||||
function handleClick() {
|
||||
// ...
|
||||
}
|
||||
</script>
|
||||
|
||||
handleClick() {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<div on:touchstart="{handleTouchstart}">
|
||||
<button on:click|stopPropagation|preventDefault="{handleClick}">click me</button>
|
||||
<button on:click|once|capture="{handleClick}">or me</button>
|
||||
<button on:click|capture="{handleClick}">or me!</button>
|
||||
</div>
|
@ -1 +1 @@
|
||||
<audio bind:buffered bind:seekable bind:played bind:currentTime bind:duration bind:paused bind:volume/>
|
||||
<audio bind:buffered bind:seekable bind:played bind:currentTime bind:duration bind:paused bind:volume/>
|
@ -1,13 +1,6 @@
|
||||
<Imported/>
|
||||
<NonImported/>
|
||||
|
||||
<script>
|
||||
import Imported from 'Imported.html';
|
||||
</script>
|
||||
|
||||
export default {
|
||||
components: {
|
||||
Imported,
|
||||
NonImported
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<Imported/>
|
||||
<NonImported/>
|
@ -1,18 +1,9 @@
|
||||
<script>
|
||||
export default {
|
||||
methods: {
|
||||
foo ( bar ) {
|
||||
console.log( bar );
|
||||
}
|
||||
},
|
||||
setup: (Component) => {
|
||||
Component.SOME_CONSTANT = 42;
|
||||
Component.factory = function (target) {
|
||||
return new Component({
|
||||
target: target
|
||||
});
|
||||
}
|
||||
Component.prototype.foo( 'baz' );
|
||||
}
|
||||
};
|
||||
<script scope="shared">
|
||||
export const SOME_CONSTANT = 42;
|
||||
</script>
|
||||
|
||||
<script>
|
||||
export function foo(bar) {
|
||||
console.log( bar );
|
||||
}
|
||||
</script>
|
@ -1,27 +1,25 @@
|
||||
<script scope="shared">
|
||||
export function preload(input) {
|
||||
return output;
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
oncreate() {
|
||||
console.log('oncreate');
|
||||
},
|
||||
import { ondestroy, onmount } from 'svelte';
|
||||
|
||||
ondestroy() {
|
||||
console.log('ondestroy');
|
||||
},
|
||||
onmount(() => {
|
||||
console.log('oncreate');
|
||||
});
|
||||
|
||||
methods: {
|
||||
foo() {
|
||||
console.log('foo');
|
||||
}
|
||||
},
|
||||
ondestroy(() => {
|
||||
console.log('ondestroy');
|
||||
});
|
||||
|
||||
events: {
|
||||
swipe(node, callback) {
|
||||
// TODO implement
|
||||
}
|
||||
},
|
||||
function foo() {
|
||||
console.log('foo');
|
||||
}
|
||||
|
||||
preload(input) {
|
||||
return output;
|
||||
}
|
||||
};
|
||||
function swipe(node, callback) {
|
||||
// TODO implement
|
||||
}
|
||||
</script>
|
@ -1,3 +1,3 @@
|
||||
<div>content</div>
|
||||
<!-- comment -->
|
||||
<div>more content</div>
|
||||
<div>more content</div>
|
@ -1,21 +1,20 @@
|
||||
<h1 use:insert="display ? `Hello ${target}` : ''"></h1>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
actions: {
|
||||
insert(node, text) {
|
||||
export let display;
|
||||
export let target;
|
||||
|
||||
function insert(node, text) {
|
||||
|
||||
function onClick() {
|
||||
node.textContent = text;
|
||||
}
|
||||
node.addEventListener('click', onClick);
|
||||
function onClick() {
|
||||
node.textContent = text;
|
||||
}
|
||||
node.addEventListener('click', onClick);
|
||||
|
||||
return {
|
||||
destroy() {
|
||||
node.removeEventListener('click', onClick);
|
||||
}
|
||||
}
|
||||
return {
|
||||
destroy() {
|
||||
node.removeEventListener('click', onClick);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
||||
<h1 use:insert="{display ? `Hello ${target}` : ''}"></h1>
|
@ -1,22 +1,20 @@
|
||||
<button use:foo>{x}</button>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
actions: {
|
||||
foo(node) {
|
||||
let x = 0;
|
||||
export let x;
|
||||
|
||||
function foo(node) {
|
||||
let x = 0;
|
||||
|
||||
const handler = () => this.set({ x: x++ });
|
||||
const handler = () => x = x++;
|
||||
|
||||
node.addEventListener('click', handler);
|
||||
handler();
|
||||
node.addEventListener('click', handler);
|
||||
handler();
|
||||
|
||||
return {
|
||||
destroy() {
|
||||
node.removeEventListener('click', handler);
|
||||
}
|
||||
};
|
||||
return {
|
||||
destroy() {
|
||||
node.removeEventListener('click', handler);
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<button use:foo>{x}</button>
|
@ -1,52 +1,44 @@
|
||||
<button use:tooltip="tooltip">action</button>
|
||||
<svelte:window on:keydown="checkForCtrl(event)" on:keyup="checkForCtrl(event)"/>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return { tooltip: 'Perform an Action' };
|
||||
},
|
||||
export let tooltip = 'Perform an Action';
|
||||
|
||||
methods: {
|
||||
checkForCtrl(event) {
|
||||
if (event.ctrlKey) {
|
||||
this.set({ tooltip: 'Perform an augmented Action' });
|
||||
} else {
|
||||
this.set({ tooltip: 'Perform an Action' });
|
||||
}
|
||||
}
|
||||
},
|
||||
function checkForCtrl(event) {
|
||||
if (event.ctrlKey) {
|
||||
tooltip = 'Perform an augmented Action';
|
||||
} else {
|
||||
tooltip = 'Perform an Action';
|
||||
}
|
||||
}
|
||||
|
||||
actions: {
|
||||
tooltip(node, text) {
|
||||
let tooltip = null;
|
||||
function tooltip(node, text) {
|
||||
let tooltip = null;
|
||||
|
||||
function onMouseEnter() {
|
||||
tooltip = document.createElement('div');
|
||||
tooltip.classList.add('tooltip');
|
||||
tooltip.textContent = text;
|
||||
node.parentNode.appendChild(tooltip);
|
||||
}
|
||||
function onMouseEnter() {
|
||||
tooltip = document.createElement('div');
|
||||
tooltip.classList.add('tooltip');
|
||||
tooltip.textContent = text;
|
||||
node.parentNode.appendChild(tooltip);
|
||||
}
|
||||
|
||||
function onMouseLeave() {
|
||||
if (!tooltip) return;
|
||||
tooltip.remove();
|
||||
tooltip = null;
|
||||
}
|
||||
function onMouseLeave() {
|
||||
if (!tooltip) return;
|
||||
tooltip.remove();
|
||||
tooltip = null;
|
||||
}
|
||||
|
||||
node.addEventListener('mouseenter', onMouseEnter);
|
||||
node.addEventListener('mouseleave', onMouseLeave);
|
||||
node.addEventListener('mouseenter', onMouseEnter);
|
||||
node.addEventListener('mouseleave', onMouseLeave);
|
||||
|
||||
return {
|
||||
update(text) {
|
||||
if (tooltip) tooltip.textContent = text;
|
||||
},
|
||||
destroy() {
|
||||
node.removeEventListener('mouseenter', onMouseEnter);
|
||||
node.removeEventListener('mouseleave', onMouseLeave);
|
||||
}
|
||||
}
|
||||
return {
|
||||
update(text) {
|
||||
if (tooltip) tooltip.textContent = text;
|
||||
},
|
||||
destroy() {
|
||||
node.removeEventListener('mouseenter', onMouseEnter);
|
||||
node.removeEventListener('mouseleave', onMouseLeave);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
||||
<button use:tooltip="{tooltip}">action</button>
|
||||
<svelte:window on:keydown="{checkForCtrl}" on:keyup="{checkForCtrl}"/>
|
@ -1,34 +1,30 @@
|
||||
<button use:tooltip="'Perform an Action'">action</button>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
actions: {
|
||||
tooltip(node, text) {
|
||||
let tooltip = null;
|
||||
function tooltip(node, text) {
|
||||
let tooltip = null;
|
||||
|
||||
function onMouseEnter() {
|
||||
tooltip = document.createElement('div');
|
||||
tooltip.classList.add('tooltip');
|
||||
tooltip.textContent = text;
|
||||
node.parentNode.appendChild(tooltip);
|
||||
}
|
||||
function onMouseEnter() {
|
||||
tooltip = document.createElement('div');
|
||||
tooltip.classList.add('tooltip');
|
||||
tooltip.textContent = text;
|
||||
node.parentNode.appendChild(tooltip);
|
||||
}
|
||||
|
||||
function onMouseLeave() {
|
||||
if (!tooltip) return;
|
||||
tooltip.remove();
|
||||
tooltip = null;
|
||||
}
|
||||
function onMouseLeave() {
|
||||
if (!tooltip) return;
|
||||
tooltip.remove();
|
||||
tooltip = null;
|
||||
}
|
||||
|
||||
node.addEventListener('mouseenter', onMouseEnter);
|
||||
node.addEventListener('mouseleave', onMouseLeave);
|
||||
|
||||
return {
|
||||
destroy() {
|
||||
node.removeEventListener('mouseenter', onMouseEnter);
|
||||
node.removeEventListener('mouseleave', onMouseLeave);
|
||||
}
|
||||
}
|
||||
node.addEventListener('mouseenter', onMouseEnter);
|
||||
node.addEventListener('mouseleave', onMouseLeave);
|
||||
|
||||
return {
|
||||
destroy() {
|
||||
node.removeEventListener('mouseenter', onMouseEnter);
|
||||
node.removeEventListener('mouseleave', onMouseLeave);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
||||
<button use:tooltip="{'Perform an Action'}">action</button>
|
@ -1,19 +1,17 @@
|
||||
{#each things as thing (thing.id)}
|
||||
<div animate:flip>{thing.name}</div>
|
||||
{/each}
|
||||
|
||||
<script>
|
||||
export default {
|
||||
animations: {
|
||||
flip(node, animation, params) {
|
||||
const dx = animation.from.left - animation.to.left;
|
||||
const dy = animation.from.top - animation.to.top;
|
||||
export let things;
|
||||
|
||||
function flip(node, animation, params) {
|
||||
const dx = animation.from.left - animation.to.left;
|
||||
const dy = animation.from.top - animation.to.top;
|
||||
|
||||
return {
|
||||
duration: 100,
|
||||
css: (t, u) => `transform: translate(${u + dx}px, ${u * dy}px)`
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
return {
|
||||
duration: 100,
|
||||
css: (t, u) => `transform: translate(${u + dx}px, ${u * dy}px)`
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
{#each things as thing (thing.id)}
|
||||
<div animate:flip>{thing.name}</div>
|
||||
{/each}
|
@ -1,23 +1,21 @@
|
||||
{#each things as thing, i (thing.id)}
|
||||
<div animate:flip="{delay: i * 10}">{thing.name}</div>
|
||||
{/each}
|
||||
|
||||
<script>
|
||||
export default {
|
||||
animations: {
|
||||
flip(node, animation, params) {
|
||||
const dx = animation.from.left - animation.to.left;
|
||||
const dy = animation.from.top - animation.to.top;
|
||||
export let things;
|
||||
|
||||
function flip(node, animation, params) {
|
||||
const dx = animation.from.left - animation.to.left;
|
||||
const dy = animation.from.top - animation.to.top;
|
||||
|
||||
return {
|
||||
delay: params.delay,
|
||||
duration: 100,
|
||||
tick: (t, u) => {
|
||||
node.dx = u * dx;
|
||||
node.dy = u * dy;
|
||||
}
|
||||
};
|
||||
return {
|
||||
delay: params.delay,
|
||||
duration: 100,
|
||||
tick: (t, u) => {
|
||||
node.dx = u * dx;
|
||||
node.dy = u * dy;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
{#each things as thing, i (thing.id)}
|
||||
<div animate:flip="{delay: i * 10}">{thing.name}</div>
|
||||
{/each}
|
@ -1,22 +1,20 @@
|
||||
{#each things as thing (thing.id)}
|
||||
<div animate:flip>{thing.name}</div>
|
||||
{/each}
|
||||
|
||||
<script>
|
||||
export default {
|
||||
animations: {
|
||||
flip(node, animation, params) {
|
||||
const dx = animation.from.left - animation.to.left;
|
||||
const dy = animation.from.top - animation.to.top;
|
||||
export let things;
|
||||
|
||||
function flip(node, animation, params) {
|
||||
const dx = animation.from.left - animation.to.left;
|
||||
const dy = animation.from.top - animation.to.top;
|
||||
|
||||
return {
|
||||
duration: 100,
|
||||
tick: (t, u) => {
|
||||
node.dx = u * dx;
|
||||
node.dy = u * dy;
|
||||
}
|
||||
};
|
||||
return {
|
||||
duration: 100,
|
||||
tick: (t, u) => {
|
||||
node.dx = u * dx;
|
||||
node.dy = u * dy;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
{#each things as thing (thing.id)}
|
||||
<div animate:flip>{thing.name}</div>
|
||||
{/each}
|
@ -1 +1 @@
|
||||
<textarea readonly="{false}"></textarea>
|
||||
<textarea readonly="{false}"></textarea>
|
@ -1 +1 @@
|
||||
<textarea readonly="{true}"></textarea>
|
||||
<textarea readonly="{true}"></textarea>
|
@ -1,3 +1,3 @@
|
||||
{#each items as item, i}
|
||||
<div class='{item.foo ? "foo" : ""} {item.bar ? "bar" : ""}'>{i + 1}</div>
|
||||
{/each}
|
||||
{/each}
|
@ -1 +1 @@
|
||||
<div><div title={'foo'}>bar</div></div>
|
||||
<div><div title={'foo'}>bar</div></div>
|
@ -1 +1 @@
|
||||
<span title='{"\"foo\""}'>foo</span>
|
||||
<span title='{"\"foo\""}'>foo</span>
|
@ -1,2 +1,2 @@
|
||||
<div class='{class}'></div>{123}
|
||||
<div class='{ class }'></div>{ 123 }
|
||||
<div class='{ class }'></div>{ 123 }
|
@ -1,9 +1,5 @@
|
||||
<div {id}/>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data: () => ({
|
||||
id: 'foo'
|
||||
})
|
||||
};
|
||||
export let id = 'foo';
|
||||
</script>
|
||||
|
||||
<div {id}/>
|
@ -1,9 +1,5 @@
|
||||
<div style='color: {color};'>{color}</div>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data: () => ({
|
||||
color: 'red'
|
||||
})
|
||||
};
|
||||
export let color = 'red';
|
||||
</script>
|
||||
|
||||
<div style='color: {color};'>{color}</div>
|
Before Width: | Height: | Size: 31 B After Width: | Height: | Size: 30 B |
@ -1 +1 @@
|
||||
<div class=''></div>
|
||||
<div class=''></div>
|
@ -1,11 +1,5 @@
|
||||
<Component value="10px"/>
|
||||
|
||||
<script>
|
||||
import Component from './Component.html';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
Component
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<Component value="10px"/>
|
@ -1,2 +1,2 @@
|
||||
<input type='radio' bind:group='foo' value='{false}'>
|
||||
<input type='radio' bind:group='foo' value='{true}'>
|
||||
<input type='radio' bind:group='foo' value='{true}'>
|
@ -1 +1 @@
|
||||
<textarea readonly></textarea>
|
||||
<textarea readonly></textarea>
|
@ -1 +1 @@
|
||||
<div class='foo'></div>
|
||||
<div class='foo'></div>
|
@ -1,13 +1,9 @@
|
||||
{#await promise then value}
|
||||
<Foo {value} />
|
||||
{/await}
|
||||
|
||||
<script>
|
||||
import Foo from './Foo.html';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
Foo
|
||||
}
|
||||
};
|
||||
</script>
|
||||
export let promise;
|
||||
</script>
|
||||
|
||||
{#await promise then value}
|
||||
<Foo {value} />
|
||||
{/await}
|
@ -1,7 +1,7 @@
|
||||
{#await thePromise}
|
||||
<p>loading...</p>
|
||||
{:then theValue}
|
||||
<button ref:button on:click='set({ clicked: theValue })'>click me</button>
|
||||
<button ref:button on:click='{() => clicked = theValue}'>click me</button>
|
||||
{:catch theError}
|
||||
<p>oh no! {theError.message}</p>
|
||||
{/await}
|
@ -1,2 +1,2 @@
|
||||
<audio bind:currentTime='t' bind:duration='d' bind:paused bind:volume='v'
|
||||
src='music.mp3'></audio>
|
||||
src='music.mp3'></audio>
|
@ -1,27 +1,22 @@
|
||||
<script>
|
||||
export let letters = [
|
||||
'a',
|
||||
'b',
|
||||
'c'
|
||||
];
|
||||
export let selected = {
|
||||
letter: ''
|
||||
};
|
||||
|
||||
function uppercase() {
|
||||
return letters.map(x => x.toUpperCase());
|
||||
}
|
||||
</script>
|
||||
|
||||
<select bind:value="selected.letter">
|
||||
{#each uppercase as letter}
|
||||
<option value="{letter}">{letter}</option>
|
||||
{/each}
|
||||
</select>
|
||||
|
||||
{selected.letter}
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
letters: [
|
||||
'a',
|
||||
'b',
|
||||
'c'
|
||||
],
|
||||
selected: {
|
||||
letter: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
computed:{
|
||||
uppercase: ({ letters }) => letters.map(x => x.toUpperCase())
|
||||
}
|
||||
};
|
||||
</script>
|
||||
{selected.letter}
|
@ -1,15 +1,13 @@
|
||||
<script>
|
||||
export let items;
|
||||
|
||||
function numCompleted() {
|
||||
return items.reduce( ( total, item ) => total + ( item.completed ? 1 : 0 ), 0 );
|
||||
}
|
||||
</script>
|
||||
|
||||
{#each items as item}
|
||||
<div><input type='checkbox' bind:checked='item.completed'><p>{item.description}</p></div>
|
||||
{/each}
|
||||
|
||||
<p>{numCompleted} completed</p>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
computed: {
|
||||
numCompleted ({ items }) {
|
||||
return items.reduce( ( total, item ) => total + ( item.completed ? 1 : 0 ), 0 );
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<p>{numCompleted()} completed</p>
|
@ -1,3 +1,3 @@
|
||||
<input type='checkbox' bind:checked bind:indeterminate>
|
||||
<p>checked? {checked}</p>
|
||||
<p>indeterminate? {indeterminate}</p>
|
||||
<p>indeterminate? {indeterminate}</p>
|
@ -1,14 +1,11 @@
|
||||
{#each cats as cat (cat.name)}
|
||||
<input type="checkbox" bind:checked="cat.checked" on:change="someCheck()">
|
||||
{/each}
|
||||
|
||||
<script>
|
||||
export default {
|
||||
oncreate() {},
|
||||
methods: {
|
||||
someCheck() {
|
||||
console.log('Check');
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
export let cats;
|
||||
|
||||
function someCheck() {
|
||||
console.log('Check');
|
||||
}
|
||||
</script>
|
||||
|
||||
{#each cats as cat (cat.name)}
|
||||
<input type="checkbox" bind:checked="cat.checked" on:change="{someCheck}">
|
||||
{/each}
|
@ -1,2 +1,2 @@
|
||||
<input type='checkbox' bind:checked='foo'>
|
||||
<p>{foo}</p>
|
||||
<p>{foo}</p>
|
@ -1,2 +1,2 @@
|
||||
<input type='number' bind:value='count'>
|
||||
<p>{typeof count} {count}</p>
|
||||
<p>{typeof count} {count}</p>
|
@ -1,2 +1,2 @@
|
||||
<input type='range' bind:value='count'>
|
||||
<p>{typeof count} {count}</p>
|
||||
<p>{typeof count} {count}</p>
|
@ -1,2 +1,2 @@
|
||||
<input type='range' bind:value='count'>
|
||||
<p>{typeof count} {count}</p>
|
||||
<p>{typeof count} {count}</p>
|
@ -1,3 +1,3 @@
|
||||
{#each items as item}
|
||||
<div><input bind:value='item'><p>{item}</p></div>
|
||||
{/each}
|
||||
{/each}
|
@ -1,2 +1,2 @@
|
||||
<input bind:value='user[prop]'>
|
||||
<p>hello {user.name}</p>
|
||||
<p>hello {user.name}</p>
|
@ -1,3 +1,3 @@
|
||||
{#each items as item}
|
||||
<div><input bind:value='item.description'><p>{item.description}</p></div>
|
||||
{/each}
|
||||
{/each}
|
@ -1,2 +1,2 @@
|
||||
<input bind:value='user.name'>
|
||||
<p>hello {user.name}</p>
|
||||
<p>hello {user.name}</p>
|
@ -1,2 +1,2 @@
|
||||
<input bind:value='name'>
|
||||
<p>hello {name}</p>
|
||||
<p>hello {name}</p>
|
@ -1 +1 @@
|
||||
<input bind:value='a' on:input='set({ b: 0 })'>
|
||||
<input bind:value='a' on:input='{() => b = 0}'>
|
@ -1,20 +1,11 @@
|
||||
<script>
|
||||
export let hidden = true;
|
||||
|
||||
export function toggle() {
|
||||
hidden = !this.get().hidden;
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if !hidden}
|
||||
<slot></slot>
|
||||
{/if}
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
hidden: true
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
toggle () {
|
||||
this.set({
|
||||
hidden: !this.get().hidden
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
{/if}
|
@ -1,2 +1,2 @@
|
||||
<textarea bind:value></textarea>
|
||||
<p>{value}</p>
|
||||
<p>{value}</p>
|
@ -1,15 +1,13 @@
|
||||
<Two bind:foo/>
|
||||
|
||||
<script>
|
||||
import { onmount } from 'svelte';
|
||||
import Two from './Two.html';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
Two
|
||||
},
|
||||
export let snapshot;
|
||||
export let foo;
|
||||
|
||||
onmount(() => {
|
||||
snapshot = foo;
|
||||
});
|
||||
</script>
|
||||
|
||||
oncreate() {
|
||||
this.snapshot = this.get().foo;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<Two bind:foo/>
|
@ -1,15 +1,7 @@
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
bar: 1
|
||||
};
|
||||
},
|
||||
export let bar = 1;
|
||||
|
||||
computed: {
|
||||
foo({ bar }) {
|
||||
return bar * 2;
|
||||
}
|
||||
}
|
||||
};
|
||||
function foo() {
|
||||
return bar * 2;
|
||||
}
|
||||
</script>
|
@ -1,9 +1,5 @@
|
||||
<One ref:one/>
|
||||
|
||||
<script>
|
||||
import One from './One.html';
|
||||
</script>
|
||||
|
||||
export default {
|
||||
components: { One }
|
||||
};
|
||||
</script>
|
||||
<One ref:one/>
|
@ -1,20 +1,12 @@
|
||||
<p>bar in Foo: {bar}</p>
|
||||
<p>baz in Foo: {baz}</p>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
bar: 1,
|
||||
baz: 2
|
||||
};
|
||||
},
|
||||
export let bar = 1;
|
||||
export let baz = 2;
|
||||
|
||||
methods: {
|
||||
double() {
|
||||
const { bar, baz } = this.get();
|
||||
this.set({ bar: bar * 2, baz: baz * 2 });
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
export function double() {
|
||||
bar = bar * 2;
|
||||
baz = baz * 2;
|
||||
}
|
||||
</script>
|
||||
|
||||
<p>bar in Foo: {bar}</p>
|
||||
<p>baz in Foo: {baz}</p>
|
@ -1,12 +1,9 @@
|
||||
<Foo ref:foo bind:bar bind:baz/>
|
||||
<p ref:p>{bar + baz}</p>
|
||||
|
||||
<script>
|
||||
import Foo from './Foo.html';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
Foo
|
||||
}
|
||||
};
|
||||
</script>
|
||||
export let bar;
|
||||
export let baz;
|
||||
</script>
|
||||
|
||||
<Foo ref:foo bind:bar bind:baz/>
|
||||
<p ref:p>{bar + baz}</p>
|
@ -1 +1 @@
|
||||
<div class:one="true"></div>
|
||||
<div class:one="true"></div>
|
@ -1,11 +1,9 @@
|
||||
<div class:active="isActive(user)"></div>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
helpers: {
|
||||
isActive(user) {
|
||||
return user.active;
|
||||
}
|
||||
}
|
||||
export let user;
|
||||
|
||||
function isActive(user) {
|
||||
return user.active;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class:active="isActive(user)"></div>
|
@ -1,3 +1,3 @@
|
||||
{#each things as thing}
|
||||
<div class:selected="selected === thing"></div>
|
||||
{/each}
|
||||
{/each}
|
@ -1 +1 @@
|
||||
<div class="{ myClass }" class:is-active class:isSelected class:not-used></div>
|
||||
<div class="{ myClass }" class:is-active class:isSelected class:not-used></div>
|
@ -1 +1 @@
|
||||
<div class:is-active class:isSelected class:not-used></div>
|
||||
<div class:is-active class:isSelected class:not-used></div>
|
@ -1 +1 @@
|
||||
<div class="one" class:two="true" class:three="true"></div>
|
||||
<div class="one" class:two="true" class:three="true"></div>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue