mirror of https://github.com/sveltejs/svelte
Merge 73ccdec9a1
into a4d412fb53
commit
ac3c4614ed
@ -0,0 +1,46 @@
|
|||||||
|
export default {
|
||||||
|
nestedTransitions: true,
|
||||||
|
transitions: {
|
||||||
|
intro: false,
|
||||||
|
outro: false,
|
||||||
|
duration: 100,
|
||||||
|
},
|
||||||
|
|
||||||
|
data: {
|
||||||
|
x: false,
|
||||||
|
y: true
|
||||||
|
},
|
||||||
|
|
||||||
|
test(assert, component, target, window, raf) {
|
||||||
|
component.set({ x: true });
|
||||||
|
|
||||||
|
let div = target.querySelector('div');
|
||||||
|
assert.equal(div.foo, undefined);
|
||||||
|
|
||||||
|
component.set({ y: false });
|
||||||
|
assert.htmlEqual(target.innerHTML, '<div></div>');
|
||||||
|
div = target.querySelector('div');
|
||||||
|
|
||||||
|
raf.tick(50);
|
||||||
|
assert.equal(div.foo, 0.5);
|
||||||
|
|
||||||
|
raf.tick(100);
|
||||||
|
assert.htmlEqual(target.innerHTML, '');
|
||||||
|
|
||||||
|
component.set({ x: false, y: true });
|
||||||
|
assert.htmlEqual(target.innerHTML, '');
|
||||||
|
|
||||||
|
component.set({ x: true });
|
||||||
|
assert.htmlEqual(target.innerHTML, '<div></div>');
|
||||||
|
div = target.querySelector('div');
|
||||||
|
|
||||||
|
component.set({ y: false });
|
||||||
|
assert.htmlEqual(target.innerHTML, '<div></div>');
|
||||||
|
|
||||||
|
raf.tick(150);
|
||||||
|
assert.equal(div.foo, 0.5);
|
||||||
|
|
||||||
|
raf.tick(200);
|
||||||
|
assert.htmlEqual(target.innerHTML, '');
|
||||||
|
},
|
||||||
|
};
|
@ -0,0 +1,19 @@
|
|||||||
|
{#if x}
|
||||||
|
{#if y}
|
||||||
|
<div transition:foo></div>
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
transitions: {
|
||||||
|
foo(node, params) {
|
||||||
|
return {
|
||||||
|
tick: t => {
|
||||||
|
node.foo = t;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
@ -0,0 +1,33 @@
|
|||||||
|
let fulfil;
|
||||||
|
|
||||||
|
const promise = new Promise(f => {
|
||||||
|
fulfil = f;
|
||||||
|
});
|
||||||
|
|
||||||
|
export default {
|
||||||
|
nestedTransitions: true,
|
||||||
|
|
||||||
|
data: {
|
||||||
|
x: false,
|
||||||
|
promise
|
||||||
|
},
|
||||||
|
|
||||||
|
test(assert, component, target, window, raf) {
|
||||||
|
component.set({ x: true });
|
||||||
|
fulfil();
|
||||||
|
|
||||||
|
return promise.then(() => {
|
||||||
|
const div = target.querySelector('div');
|
||||||
|
assert.equal(div.foo, 0);
|
||||||
|
|
||||||
|
raf.tick(100);
|
||||||
|
assert.equal(div.foo, 1);
|
||||||
|
|
||||||
|
component.set({ x: false });
|
||||||
|
assert.htmlEqual(target.innerHTML, '');
|
||||||
|
|
||||||
|
raf.tick(150);
|
||||||
|
assert.equal(div.foo, 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,22 @@
|
|||||||
|
{#if x}
|
||||||
|
{#await promise then value}
|
||||||
|
<div transition:foo></div>
|
||||||
|
{/await}
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
transitions: {
|
||||||
|
foo(node, params) {
|
||||||
|
return {
|
||||||
|
intro: false,
|
||||||
|
outro: false,
|
||||||
|
duration: 100,
|
||||||
|
tick: t => {
|
||||||
|
node.foo = t;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
@ -0,0 +1,18 @@
|
|||||||
|
<div transition:foo></div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
transitions: {
|
||||||
|
foo(node, params) {
|
||||||
|
return {
|
||||||
|
intro: false,
|
||||||
|
outro: false,
|
||||||
|
duration: 100,
|
||||||
|
tick: t => {
|
||||||
|
node.foo = t;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
@ -0,0 +1,26 @@
|
|||||||
|
export default {
|
||||||
|
nestedTransitions: true,
|
||||||
|
|
||||||
|
data: {
|
||||||
|
x: false
|
||||||
|
},
|
||||||
|
|
||||||
|
test(assert, component, target, window, raf) {
|
||||||
|
component.set({ x: true });
|
||||||
|
|
||||||
|
const div = target.querySelector('div');
|
||||||
|
assert.equal(div.foo, 0);
|
||||||
|
|
||||||
|
raf.tick(100);
|
||||||
|
assert.equal(div.foo, 1);
|
||||||
|
|
||||||
|
component.set({ x: false });
|
||||||
|
assert.htmlEqual(target.innerHTML, '<div></div>');
|
||||||
|
|
||||||
|
raf.tick(150);
|
||||||
|
assert.equal(div.foo, 0.5);
|
||||||
|
|
||||||
|
raf.tick(200);
|
||||||
|
assert.htmlEqual(target.innerHTML, '');
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,13 @@
|
|||||||
|
{#if x}
|
||||||
|
<Widget/>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import Widget from './Widget.html';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
Widget: './Widget.html'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
@ -0,0 +1,32 @@
|
|||||||
|
export default {
|
||||||
|
nestedTransitions: true,
|
||||||
|
|
||||||
|
data: {
|
||||||
|
x: false,
|
||||||
|
things: ['a']
|
||||||
|
},
|
||||||
|
|
||||||
|
test(assert, component, target, window, raf) {
|
||||||
|
component.set({ x: true });
|
||||||
|
|
||||||
|
const div1 = target.querySelector('div');
|
||||||
|
assert.equal(div1.foo, undefined);
|
||||||
|
|
||||||
|
raf.tick(100);
|
||||||
|
assert.equal(div1.foo, undefined);
|
||||||
|
|
||||||
|
component.set({ things: ['a', 'b'] });
|
||||||
|
assert.htmlEqual(target.innerHTML, '<div></div><div></div>');
|
||||||
|
|
||||||
|
const div2 = target.querySelector('div:last-child');
|
||||||
|
assert.equal(div1.foo, undefined);
|
||||||
|
assert.equal(div2.foo, 0);
|
||||||
|
|
||||||
|
raf.tick(200);
|
||||||
|
assert.equal(div1.foo, undefined);
|
||||||
|
assert.equal(div2.foo, 1);
|
||||||
|
|
||||||
|
component.set({ x: false });
|
||||||
|
assert.htmlEqual(target.innerHTML, '');
|
||||||
|
},
|
||||||
|
};
|
@ -0,0 +1,22 @@
|
|||||||
|
{#if x}
|
||||||
|
{#each things as thing (thing)}
|
||||||
|
<div transition:foo></div>
|
||||||
|
{/each}
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
transitions: {
|
||||||
|
foo(node, params) {
|
||||||
|
return {
|
||||||
|
intro: false,
|
||||||
|
outro: false,
|
||||||
|
duration: 100,
|
||||||
|
tick: t => {
|
||||||
|
node.foo = t;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
@ -0,0 +1,32 @@
|
|||||||
|
export default {
|
||||||
|
nestedTransitions: true,
|
||||||
|
|
||||||
|
data: {
|
||||||
|
x: false,
|
||||||
|
things: ['a']
|
||||||
|
},
|
||||||
|
|
||||||
|
test(assert, component, target, window, raf) {
|
||||||
|
component.set({ x: true });
|
||||||
|
|
||||||
|
const div1 = target.querySelector('div');
|
||||||
|
assert.equal(div1.foo, undefined);
|
||||||
|
|
||||||
|
raf.tick(100);
|
||||||
|
assert.equal(div1.foo, undefined);
|
||||||
|
|
||||||
|
component.set({ things: ['a', 'b'] });
|
||||||
|
assert.htmlEqual(target.innerHTML, '<div></div><div></div>');
|
||||||
|
|
||||||
|
const div2 = target.querySelector('div:last-child');
|
||||||
|
assert.equal(div1.foo, undefined);
|
||||||
|
assert.equal(div2.foo, 0);
|
||||||
|
|
||||||
|
raf.tick(200);
|
||||||
|
assert.equal(div1.foo, undefined);
|
||||||
|
assert.equal(div2.foo, 1);
|
||||||
|
|
||||||
|
component.set({ x: false });
|
||||||
|
assert.htmlEqual(target.innerHTML, '');
|
||||||
|
},
|
||||||
|
};
|
@ -0,0 +1,22 @@
|
|||||||
|
{#if x}
|
||||||
|
{#each things as thing}
|
||||||
|
<div transition:foo></div>
|
||||||
|
{/each}
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
transitions: {
|
||||||
|
foo(node, params) {
|
||||||
|
return {
|
||||||
|
intro: false,
|
||||||
|
outro: false,
|
||||||
|
duration: 100,
|
||||||
|
tick: t => {
|
||||||
|
node.foo = t;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
@ -0,0 +1,41 @@
|
|||||||
|
export default {
|
||||||
|
nestedTransitions: true,
|
||||||
|
|
||||||
|
data: {
|
||||||
|
x: false,
|
||||||
|
y: true
|
||||||
|
},
|
||||||
|
|
||||||
|
test(assert, component, target, window, raf) {
|
||||||
|
component.set({ x: true });
|
||||||
|
|
||||||
|
let div = target.querySelector('div');
|
||||||
|
assert.equal(div.foo, undefined);
|
||||||
|
|
||||||
|
component.set({ y: false });
|
||||||
|
assert.htmlEqual(target.innerHTML, '<div></div>');
|
||||||
|
div = target.querySelector('div');
|
||||||
|
|
||||||
|
raf.tick(50);
|
||||||
|
assert.equal(div.foo, 0.5);
|
||||||
|
|
||||||
|
raf.tick(100);
|
||||||
|
assert.htmlEqual(target.innerHTML, '');
|
||||||
|
|
||||||
|
component.set({ x: false, y: true });
|
||||||
|
assert.htmlEqual(target.innerHTML, '');
|
||||||
|
|
||||||
|
component.set({ x: true });
|
||||||
|
assert.htmlEqual(target.innerHTML, '<div></div>');
|
||||||
|
div = target.querySelector('div');
|
||||||
|
|
||||||
|
component.set({ y: false });
|
||||||
|
assert.htmlEqual(target.innerHTML, '<div></div>');
|
||||||
|
|
||||||
|
raf.tick(150);
|
||||||
|
assert.equal(div.foo, 0.5);
|
||||||
|
|
||||||
|
raf.tick(200);
|
||||||
|
assert.htmlEqual(target.innerHTML, '');
|
||||||
|
},
|
||||||
|
};
|
@ -0,0 +1,22 @@
|
|||||||
|
{#if x}
|
||||||
|
{#if y}
|
||||||
|
<div transition:foo></div>
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
transitions: {
|
||||||
|
foo(node, params) {
|
||||||
|
return {
|
||||||
|
intro: false,
|
||||||
|
outro: false,
|
||||||
|
duration: 100,
|
||||||
|
tick: t => {
|
||||||
|
node.foo = t;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
Loading…
Reference in new issue