-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix slot data for cancelled transition
- Loading branch information
Showing
16 changed files
with
370 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// cancelled the transition halfway | ||
export default { | ||
html: ` | ||
<div>Foo</div> | ||
|
19 changes: 19 additions & 0 deletions
19
test/runtime/samples/transition-js-slot-4-cancelled/Nested.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<script> | ||
export let visible; | ||
export let slotProps; | ||
function fade(node) { | ||
return { | ||
duration: 100, | ||
tick: t => { | ||
node.foo = t; | ||
} | ||
}; | ||
} | ||
</script> | ||
|
||
{#if visible} | ||
<div transition:fade> | ||
<slot {slotProps}></slot> | ||
</div> | ||
{/if} |
35 changes: 35 additions & 0 deletions
35
test/runtime/samples/transition-js-slot-4-cancelled/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// updated props in the middle of transitions | ||
// and cancelled the transition halfway | ||
export default { | ||
html: ` | ||
<div>outside Foo Foo Foo</div> | ||
<div>inside Foo Foo Foo</div> | ||
`, | ||
props: { | ||
props: 'Foo' | ||
}, | ||
|
||
async test({ assert, component, target, window, raf }) { | ||
await component.hide(); | ||
const [, div] = target.querySelectorAll('div'); | ||
|
||
raf.tick(50); | ||
assert.equal(div.foo, 0.5); | ||
|
||
component.props = 'Bar'; | ||
assert.htmlEqual(target.innerHTML, ` | ||
<div>outside Bar Bar Bar</div> | ||
<div>inside Foo Foo Foo</div> | ||
`); | ||
|
||
await component.show(); | ||
|
||
assert.htmlEqual(target.innerHTML, ` | ||
<div>outside Bar Bar Bar</div> | ||
<div>inside Bar Bar Bar</div> | ||
`); | ||
|
||
raf.tick(100); | ||
assert.equal(div.foo, 1); | ||
} | ||
}; |
22 changes: 22 additions & 0 deletions
22
test/runtime/samples/transition-js-slot-4-cancelled/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<script> | ||
import Nested from './Nested.svelte'; | ||
let visible = true; | ||
let state = 'Foo'; | ||
let slotProps = 'Foo'; | ||
export let props; | ||
export function show() { | ||
visible = true; | ||
} | ||
export function hide() { | ||
visible = false; | ||
state = 'Bar'; | ||
slotProps = 'Bar'; | ||
} | ||
</script> | ||
|
||
<div>outside {state} {props} {slotProps}</div> | ||
<Nested {visible} {slotProps} let:slotProps> | ||
inside {state} {props} {slotProps} | ||
</Nested> |
19 changes: 19 additions & 0 deletions
19
test/runtime/samples/transition-js-slot-5-cancelled-overflow/Nested.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<script> | ||
export let visible; | ||
export let slotProps; | ||
function fade(node) { | ||
return { | ||
duration: 100, | ||
tick: t => { | ||
node.foo = t; | ||
} | ||
}; | ||
} | ||
</script> | ||
|
||
{#if visible} | ||
<div transition:fade> | ||
<slot {slotProps}></slot> | ||
</div> | ||
{/if} |
40 changes: 40 additions & 0 deletions
40
test/runtime/samples/transition-js-slot-5-cancelled-overflow/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// updated props in the middle of transitions | ||
// and cancelled the transition halfway | ||
// + spreaded props + overflow context | ||
|
||
export default { | ||
html: ` | ||
<div>outside Foo Foo Foo</div> | ||
<div>inside Foo Foo Foo</div> | ||
0 | ||
`, | ||
props: { | ||
props: 'Foo' | ||
}, | ||
|
||
async test({ assert, component, target, window, raf }) { | ||
await component.hide(); | ||
const [, div] = target.querySelectorAll('div'); | ||
|
||
raf.tick(50); | ||
assert.equal(div.foo, 0.5); | ||
|
||
component.props = 'Bar'; | ||
assert.htmlEqual(target.innerHTML, ` | ||
<div>outside Bar Bar Bar</div> | ||
<div>inside Foo Foo Foo</div> | ||
0 | ||
`); | ||
|
||
await component.show(); | ||
|
||
assert.htmlEqual(target.innerHTML, ` | ||
<div>outside Bar Bar Bar</div> | ||
<div>inside Bar Bar Bar</div> | ||
0 | ||
`); | ||
|
||
raf.tick(100); | ||
assert.equal(div.foo, 1); | ||
} | ||
}; |
27 changes: 27 additions & 0 deletions
27
test/runtime/samples/transition-js-slot-5-cancelled-overflow/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<script> | ||
import Nested from './Nested.svelte'; | ||
export let a1=0,a2=0,a3=0,a4=0,a5=0,a6=0,a7=0,a8=0,a9=0,a10=0,a11=0, a12=0,a13=0,a14=0,a15=0,a16=0,a17=0,a18=0,a19=0,a20=0,a21=0, a22=0,a23=0,a24=0,a25=0,a26=0,a27=0,a28=0,a29=0,a30=0,a31=0,a32=0,a33=0; | ||
let visible = true; | ||
let state = 'Foo'; | ||
let slotProps = 'Foo'; | ||
export let props; | ||
export function show() { | ||
visible = true; | ||
} | ||
export function hide() { | ||
visible = false; | ||
state = 'Bar'; | ||
slotProps = 'Bar'; | ||
} | ||
</script> | ||
|
||
<div>outside {state} {props} {slotProps}</div> | ||
|
||
<Nested {visible} {slotProps} let:slotProps> | ||
inside {state} {props} {slotProps} | ||
</Nested> | ||
|
||
{a1+a2+a3+a4+a5+a6+a7+a8+a9+a10+a11+a12+a13+a14+a15+a16+a17+a18+a19+a20+a21+a22+a23+a24+a25+a26+a27+a28+a29+a30+a31+a32+a33} |
19 changes: 19 additions & 0 deletions
19
test/runtime/samples/transition-js-slot-6-spread-cancelled/Nested.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<script> | ||
export let visible; | ||
export let slotProps; | ||
function fade(node) { | ||
return { | ||
duration: 100, | ||
tick: t => { | ||
node.foo = t; | ||
} | ||
}; | ||
} | ||
</script> | ||
|
||
{#if visible} | ||
<div transition:fade> | ||
<slot {...slotProps}></slot> | ||
</div> | ||
{/if} |
19 changes: 19 additions & 0 deletions
19
test/runtime/samples/transition-js-slot-6-spread-cancelled/Nested2.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<script> | ||
export let visible; | ||
let slotProps = { slotProps: 'XXX' }; | ||
function fade(node) { | ||
return { | ||
duration: 100, | ||
tick: t => { | ||
node.foo = t; | ||
} | ||
}; | ||
} | ||
</script> | ||
|
||
{#if visible} | ||
<div transition:fade> | ||
<slot {...slotProps}></slot> | ||
</div> | ||
{/if} |
40 changes: 40 additions & 0 deletions
40
test/runtime/samples/transition-js-slot-6-spread-cancelled/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// updated props in the middle of transitions | ||
// and cancelled the transition halfway | ||
// with spreaded props | ||
|
||
export default { | ||
html: ` | ||
<div>outside Foo Foo Foo</div> | ||
<div>inside Foo Foo Foo</div> | ||
<div>inside Foo Foo XXX</div> | ||
`, | ||
props: { | ||
props: 'Foo' | ||
}, | ||
|
||
async test({ assert, component, target, window, raf }) { | ||
await component.hide(); | ||
const [, div] = target.querySelectorAll('div'); | ||
|
||
raf.tick(50); | ||
assert.equal(div.foo, 0.5); | ||
|
||
component.props = 'Bar'; | ||
assert.htmlEqual(target.innerHTML, ` | ||
<div>outside Bar Bar Bar</div> | ||
<div>inside Foo Foo Foo</div> | ||
<div>inside Foo Foo XXX</div> | ||
`); | ||
|
||
await component.show(); | ||
|
||
assert.htmlEqual(target.innerHTML, ` | ||
<div>outside Bar Bar Bar</div> | ||
<div>inside Bar Bar Bar</div> | ||
<div>inside Bar Bar XXX</div> | ||
`); | ||
|
||
raf.tick(100); | ||
assert.equal(div.foo, 1); | ||
} | ||
}; |
26 changes: 26 additions & 0 deletions
26
test/runtime/samples/transition-js-slot-6-spread-cancelled/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<script> | ||
import Nested from './Nested.svelte'; | ||
import Nested2 from './Nested2.svelte'; | ||
let visible = true; | ||
let state = 'Foo'; | ||
let slotProps = { slotProps: 'Foo' }; | ||
export let props; | ||
export function show() { | ||
visible = true; | ||
} | ||
export function hide() { | ||
visible = false; | ||
state = 'Bar'; | ||
slotProps = { slotProps: 'Bar' }; | ||
} | ||
</script> | ||
|
||
<div>outside {state} {props} {slotProps.slotProps}</div> | ||
<Nested {visible} {slotProps} let:slotProps> | ||
inside {state} {props} {slotProps} | ||
</Nested> | ||
<Nested2 {visible} let:slotProps> | ||
inside {state} {props} {slotProps} | ||
</Nested2> |
19 changes: 19 additions & 0 deletions
19
test/runtime/samples/transition-js-slot-7-spread-cancelled-overflow/Nested.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<script> | ||
export let visible; | ||
export let slotProps; | ||
function fade(node) { | ||
return { | ||
duration: 100, | ||
tick: t => { | ||
node.foo = t; | ||
} | ||
}; | ||
} | ||
</script> | ||
|
||
{#if visible} | ||
<div transition:fade> | ||
<slot {...slotProps}></slot> | ||
</div> | ||
{/if} |
Oops, something went wrong.