mirror of https://github.com/sveltejs/svelte
				
				
				
			fix: allow transition undefined payload + microtask queue handling (#10117)
	
		
	
				
					
				
			* fix: allow transition undefined payload * cleanup * cleanup * add microtask queue handlingpull/10121/head
							parent
							
								
									b3d185da29
								
							
						
					
					
						commit
						05789daff9
					
				| @ -0,0 +1,5 @@ | ||||
| --- | ||||
| 'svelte': patch | ||||
| --- | ||||
| 
 | ||||
| fix: allow transition undefined payload | ||||
| @ -0,0 +1,40 @@ | ||||
| import { flushSync } from 'svelte'; | ||||
| import { test } from '../../test'; | ||||
| 
 | ||||
| export default test({ | ||||
| 	html: `<button>show</button><button>animate</button>`, | ||||
| 
 | ||||
| 	async test({ assert, target }) { | ||||
| 		const [btn1, btn2] = target.querySelectorAll('button'); | ||||
| 
 | ||||
| 		flushSync(() => { | ||||
| 			btn1.click(); | ||||
| 		}); | ||||
| 
 | ||||
| 		assert.htmlEqual( | ||||
| 			target.innerHTML, | ||||
| 			`<button>show</button><button>animate</button><h1>Hello\n!</h1>` | ||||
| 		); | ||||
| 
 | ||||
| 		flushSync(() => { | ||||
| 			btn1.click(); | ||||
| 		}); | ||||
| 
 | ||||
| 		assert.htmlEqual(target.innerHTML, `<button>show</button><button>animate</button>`); | ||||
| 
 | ||||
| 		flushSync(() => { | ||||
| 			btn2.click(); | ||||
| 		}); | ||||
| 
 | ||||
| 		assert.htmlEqual(target.innerHTML, `<button>show</button><button>animate</button>`); | ||||
| 
 | ||||
| 		flushSync(() => { | ||||
| 			btn1.click(); | ||||
| 		}); | ||||
| 
 | ||||
| 		assert.htmlEqual( | ||||
| 			target.innerHTML, | ||||
| 			`<button>show</button><button>animate</button><h1 style="opacity: 0;">Hello\n!</h1>` | ||||
| 		); | ||||
| 	} | ||||
| }); | ||||
| @ -0,0 +1,16 @@ | ||||
| <script> | ||||
| 	import { fade } from 'svelte/transition'; | ||||
| 
 | ||||
| 	let show = $state(false); | ||||
| 	let animate = $state(false); | ||||
| 
 | ||||
| 	function maybe(node, animate) { | ||||
| 		if (animate) return fade(node); | ||||
| 	} | ||||
| </script> | ||||
| 
 | ||||
| <button onclick={() => show = !show}>show</button><button onclick={() => animate = !animate}>animate</button> | ||||
| 
 | ||||
| {#if show} | ||||
| 	<h1 transition:maybe={animate}>Hello {name}!</h1> | ||||
| {/if} | ||||
					Loading…
					
					
				
		Reference in new issue