File tree Expand file tree Collapse file tree 1 file changed +18
-22
lines changed
packages/svelte/src/compiler/phases/3-transform/client/transform-template Expand file tree Collapse file tree 1 file changed +18
-22
lines changed Original file line number Diff line number Diff line change @@ -14,33 +14,29 @@ export function template_to_string(items) {
1414 * @param {Node } node
1515 */
1616function stringify ( node ) {
17- switch ( node . type ) {
18- case 'element' : {
19- let str = `<${ node . name } ` ;
20-
21- for ( const key in node . attributes ) {
22- const value = node . attributes [ key ] ;
17+ if ( node . type === 'text' ) {
18+ return node . nodes . map ( ( node ) => node . raw ) . join ( '' ) ;
19+ }
2320
24- str += ` ${ key } ` ;
25- if ( value !== undefined ) str += `=" ${ escape_html ( value , true ) } "` ;
26- }
21+ if ( node . type === 'anchor' ) {
22+ return node . data ? `<!-- ${ node . data } -->` : '<!>' ;
23+ }
2724
28- str += `>` ;
29- str += node . children . map ( stringify ) . join ( '' ) ;
25+ let str = `<${ node . name } ` ;
3026
31- if ( ! is_void ( node . name ) ) {
32- str += `</${ node . name } >` ;
33- }
27+ for ( const key in node . attributes ) {
28+ const value = node . attributes [ key ] ;
3429
35- return str ;
36- }
30+ str += ` ${ key } ` ;
31+ if ( value !== undefined ) str += `="${ escape_html ( value , true ) } "` ;
32+ }
3733
38- case 'text' : {
39- return node . nodes . map ( ( node ) => node . raw ) . join ( '' ) ;
40- }
34+ str += `>` ;
35+ str += node . children . map ( stringify ) . join ( '' ) ;
4136
42- case 'anchor' : {
43- return node . data ? `<!--${ node . data } -->` : '<!>' ;
44- }
37+ if ( ! is_void ( node . name ) ) {
38+ str += `</${ node . name } >` ;
4539 }
40+
41+ return str ;
4642}
You can’t perform that action at this time.
0 commit comments