mirror of https://github.com/sveltejs/svelte
				
				
				
			
						commit
						df33187115
					
				| @ -0,0 +1,21 @@ | |||||||
|  | <script> | ||||||
|  | 	import { beforeUpdate } from 'svelte'; | ||||||
|  | 
 | ||||||
|  | 	export let a, b, c; | ||||||
|  | 
 | ||||||
|  | 	let changed = {}; | ||||||
|  | 	let previous = {}; | ||||||
|  | 
 | ||||||
|  | 	beforeUpdate(() => { | ||||||
|  | 		changed.a = a !== previous.a; | ||||||
|  | 		changed.b = b !== previous.b; | ||||||
|  | 		changed.c = c !== previous.c; | ||||||
|  | 
 | ||||||
|  | 		previous.a = a; | ||||||
|  | 		previous.b = b; | ||||||
|  | 		previous.c = c; | ||||||
|  | 	}); | ||||||
|  | </script> | ||||||
|  | 
 | ||||||
|  | <pre>{JSON.stringify({ a, b, c })}</pre> | ||||||
|  | <pre>{JSON.stringify(changed)}</pre> | ||||||
| @ -0,0 +1,20 @@ | |||||||
|  | export default { | ||||||
|  | 	html: ` | ||||||
|  | 		<pre>{"a":1,"b":[1],"c":42}</pre> | ||||||
|  | 		<pre>{"a":false,"b":false,"c":false}</pre> | ||||||
|  | 	`,
 | ||||||
|  | 
 | ||||||
|  | 	ssrHtml: ` | ||||||
|  | 		<pre>{"a":1,"b":[1],"c":42}</pre> | ||||||
|  | 		<pre>{}</pre> | ||||||
|  | 	`,
 | ||||||
|  | 
 | ||||||
|  | 	test({ assert, component, target }) { | ||||||
|  | 		component.a = 2; | ||||||
|  | 
 | ||||||
|  | 		assert.htmlEqual(target.innerHTML, ` | ||||||
|  | 			<pre>{"a":2,"b":[1],"c":42}</pre> | ||||||
|  | 			<pre>{"a":true,"b":false,"c":false}</pre> | ||||||
|  | 		`);
 | ||||||
|  | 	} | ||||||
|  | }; | ||||||
| @ -0,0 +1,8 @@ | |||||||
|  | <script> | ||||||
|  | 	import Nested from './Nested.svelte'; | ||||||
|  | 
 | ||||||
|  | 	export let a = 1; | ||||||
|  | 	let x = {}; | ||||||
|  | </script> | ||||||
|  | 
 | ||||||
|  | <Nested {...x} {a} b={[1]} c={42}/> | ||||||
					Loading…
					
					
				
		Reference in new issue