mirror of https://github.com/sveltejs/svelte
				
				
				
			
						commit
						50f8c856c9
					
				| @ -0,0 +1,25 @@ | |||||||
|  | export default { | ||||||
|  | 	props: { | ||||||
|  | 		tree: [ | ||||||
|  | 			{id: 1, sub: null}, | ||||||
|  | 			{id: 2, sub: [{id: 11}]} | ||||||
|  | 		] | ||||||
|  | 	}, | ||||||
|  | 
 | ||||||
|  | 	html: ` | ||||||
|  | 		<div>1</div> | ||||||
|  | 		<div>2\n<div>11</div></div> | ||||||
|  | 	`,
 | ||||||
|  | 
 | ||||||
|  | 	test({ assert, component, target }) { | ||||||
|  | 		component.tree = [ | ||||||
|  | 			{id: 1, sub: null}, | ||||||
|  | 			{id: 2, sub: null} | ||||||
|  | 		]; | ||||||
|  | 
 | ||||||
|  | 		assert.htmlEqual(target.innerHTML, ` | ||||||
|  | 			<div>1</div> | ||||||
|  | 			<div>2</div> | ||||||
|  | 		`);
 | ||||||
|  | 	} | ||||||
|  | }; | ||||||
| @ -0,0 +1,12 @@ | |||||||
|  | <script> | ||||||
|  | 	export let tree; | ||||||
|  | </script> | ||||||
|  | 
 | ||||||
|  | {#each tree as item, i (item.id)} | ||||||
|  | 	<div> | ||||||
|  | 		{item.id} | ||||||
|  | 		{#if item.sub} | ||||||
|  | 			<svelte:self tree={item.sub}/> | ||||||
|  | 		{/if} | ||||||
|  | 	</div> | ||||||
|  | {/each} | ||||||
					Loading…
					
					
				
		Reference in new issue