mirror of https://github.com/sveltejs/svelte
				
				
				
			allow arbitrary expressions in each block keys - fixes #703
	
		
	
				
					
				
			
							parent
							
								
									dbab1a886d
								
							
						
					
					
						commit
						8dc17b77db
					
				@ -0,0 +1,31 @@
 | 
				
			|||||||
 | 
					export default {
 | 
				
			||||||
 | 
						data: {
 | 
				
			||||||
 | 
							words: ['foo', 'bar', 'baz']
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						html: `
 | 
				
			||||||
 | 
							<p>foo</p>
 | 
				
			||||||
 | 
							<p>bar</p>
 | 
				
			||||||
 | 
							<p>baz</p>
 | 
				
			||||||
 | 
						`,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						test(assert, component, target) {
 | 
				
			||||||
 | 
							const [p1, p2, p3] = target.querySelectorAll('p');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							component.set({
 | 
				
			||||||
 | 
								words: ['foo', 'baz'],
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							assert.htmlEqual(target.innerHTML, `
 | 
				
			||||||
 | 
								<p>foo</p>
 | 
				
			||||||
 | 
								<p>baz</p>
 | 
				
			||||||
 | 
							`);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							const [p4, p5] = target.querySelectorAll('p');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							assert.ok(!target.contains(p2), '<p> element should be removed');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							assert.equal(p1, p4, 'first <p> element should be retained');
 | 
				
			||||||
 | 
							assert.equal(p3, p5, 'last <p> element should be retained');
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					{#each words as word (word)}
 | 
				
			||||||
 | 
						<p>{word}</p>
 | 
				
			||||||
 | 
					{/each}
 | 
				
			||||||
					Loading…
					
					
				
		Reference in new issue