mirror of https://github.com/sveltejs/svelte
				
				
				
			fixes #7948 - The assignment of the variable "previous_tag" was incorrectly positioned and could cause race condition when used with transitions. - We need another variable to detect when we are in a transition to remove a node --------- Co-authored-by: Yuichiro Yamashita <xydybaseball@gmail.com>pull/8335/head
							parent
							
								
									60a205edb8
								
							
						
					
					
						commit
						69c199feac
					
				@ -0,0 +1,19 @@
 | 
				
			||||
export default {
 | 
				
			||||
	async test({ assert, target, raf }) {
 | 
				
			||||
		const button = target.querySelector('#button');
 | 
				
			||||
		const container = target.querySelector('#container');
 | 
				
			||||
 | 
				
			||||
		// Multiple click on button
 | 
				
			||||
		await button.dispatchEvent(new window.MouseEvent('click'));
 | 
				
			||||
		await button.dispatchEvent(new window.MouseEvent('click'));
 | 
				
			||||
		await button.dispatchEvent(new window.MouseEvent('click'));
 | 
				
			||||
		await button.dispatchEvent(new window.MouseEvent('click'));
 | 
				
			||||
		await button.dispatchEvent(new window.MouseEvent('click'));
 | 
				
			||||
		await button.dispatchEvent(new window.MouseEvent('click'));
 | 
				
			||||
		await button.dispatchEvent(new window.MouseEvent('click'));
 | 
				
			||||
 | 
				
			||||
		assert.equal(container.children.length, 1);
 | 
				
			||||
		raf.tick(501);
 | 
				
			||||
		assert.equal(container.children.length, 0);
 | 
				
			||||
	}
 | 
				
			||||
};
 | 
				
			||||
@ -0,0 +1,13 @@
 | 
				
			||||
<script>
 | 
				
			||||
	import { slide } from 'svelte/transition';
 | 
				
			||||
	let tag = 'div';
 | 
				
			||||
	function toggle() {
 | 
				
			||||
		tag = (tag) ? null : 'div';
 | 
				
			||||
	}
 | 
				
			||||
</script>
 | 
				
			||||
 | 
				
			||||
<button id="button" on:click={toggle}>toggle</button> TAG={tag}
 | 
				
			||||
 | 
				
			||||
<div id="container">
 | 
				
			||||
	<svelte:element this={tag} transition:slide={{duration:500}}>CONTENT</svelte:element>	
 | 
				
			||||
</div>
 | 
				
			||||
					Loading…
					
					
				
		Reference in new issue