File tree Expand file tree Collapse file tree 10 files changed +37
-15
lines changed
dynamic-element-expression
dynamic-element-pass-props
dynamic-element-variable-2 Expand file tree Collapse file tree 10 files changed +37
-15
lines changed Original file line number Diff line number Diff line change 11export default {
2- html : '<div>Test </div>'
2+ html : '<div>Foo </div>'
33} ;
Original file line number Diff line number Diff line change 1- <svelte:element tag ={" div" }>Test </svelte:element >
1+ <svelte:element tag ={" div" }>Foo </svelte:element >
Original file line number Diff line number Diff line change 1+ let clicked = false ;
2+
3+ export default {
4+ props : {
5+ tag : 'div' ,
6+ onClick : ( ) => clicked = true
7+ } ,
8+ html : '<div style="display: inline;">Foo</div>' ,
9+
10+ async test ( { assert, target, window } ) {
11+ const div = target . querySelector ( 'div' ) ;
12+ await div . dispatchEvent ( new window . MouseEvent ( 'click' ) ) ;
13+
14+ assert . equal ( clicked , true ) ;
15+ }
16+ } ;
Original file line number Diff line number Diff line change 1+ <script >
2+ const tag = " div" ;
3+ export let onClick;
4+ </script >
5+
6+ <svelte:element tag ={tag } style ="display: inline;" on:click ={onClick }>Foo</svelte:element >
Original file line number Diff line number Diff line change 11export default {
2- html : '<div>Test </div>'
2+ html : '<div>Foo </div>'
33} ;
Original file line number Diff line number Diff line change 1- <svelte:element tag =" div" >Test </svelte:element >
1+ <svelte:element tag =" div" >Foo </svelte:element >
Original file line number Diff line number Diff line change 11export default {
22 props : {
33 tag : 'div' ,
4- text : 'Test '
4+ text : 'Foo '
55 } ,
6- html : '<div>Test </div>' ,
6+ html : '<div>Foo </div>' ,
77
88 test ( { assert, component, target } ) {
99 const div = target . firstChild ;
10- component . text = 'Wow ' ;
10+ component . text = 'Bar ' ;
1111
1212 assert . htmlEqual (
1313 target . innerHTML ,
1414 `
15- <div>Wow </div>
15+ <div>Bar </div>
1616 `
1717 ) ;
1818
19- // Svelte is reusing element
19+ // Re-use element since tag has not changed
2020 assert . equal ( div , target . firstChild ) ;
2121 }
2222} ;
Original file line number Diff line number Diff line change 11<script >
22 const tag = " div" ;
3- export let text = " Test " ;
3+ export let text = " Foo " ;
44 </script >
55
66<svelte:element tag ={tag }>{text }</svelte:element >
Original file line number Diff line number Diff line change 11export default {
22 props : {
33 tag : 'div' ,
4- text : 'Test '
4+ text : 'Foo '
55 } ,
6- html : '<div>Test </div>' ,
6+ html : '<div>Foo </div>' ,
77
88 test ( { assert, component, target } ) {
99 const div = target . firstChild ;
1010 component . tag = 'h1' ;
11- component . text = 'Wow ' ;
11+ component . text = 'Bar ' ;
1212
1313 assert . htmlEqual ( target . innerHTML , `
14- <h1>Wow </h1>
14+ <h1>Bar </h1>
1515 ` ) ;
1616
1717 const h1 = target . firstChild ;
Original file line number Diff line number Diff line change 11<script >
22 export let tag = " div" ;
3- export let text = " Test " ;
3+ export let text = " Foo " ;
44 </script >
55
66<svelte:element tag ={tag }>{text }</svelte:element >
You can’t perform that action at this time.
0 commit comments