@@ -476,35 +476,28 @@ function read_sequence(parser: Parser, done: () => boolean): Node[] {
476476 start : parser . index ,
477477 end : null ,
478478 type : 'Text' ,
479- data : '' ,
479+ raw : '' ,
480+ data : null
480481 } ;
481482
483+ function flush ( ) {
484+ if ( current_chunk . raw ) {
485+ current_chunk . data = decode_character_references ( current_chunk . raw ) ;
486+ current_chunk . end = parser . index ;
487+ chunks . push ( current_chunk ) ;
488+ }
489+ }
490+
482491 const chunks : Node [ ] = [ ] ;
483492
484493 while ( parser . index < parser . template . length ) {
485494 const index = parser . index ;
486495
487496 if ( done ( ) ) {
488- current_chunk . end = parser . index ;
489-
490- if ( current_chunk . data ) chunks . push ( current_chunk ) ;
491-
492- chunks . forEach ( chunk => {
493- if ( chunk . type === 'Text' ) {
494- let decoded = decode_character_references ( chunk . data ) ;
495- if ( chunk . data != decoded ) {
496- chunk . raw = chunk . data ;
497- chunk . data = decoded ;
498- }
499- }
500- } ) ;
501-
497+ flush ( ) ;
502498 return chunks ;
503499 } else if ( parser . eat ( '{' ) ) {
504- if ( current_chunk . data ) {
505- current_chunk . end = index ;
506- chunks . push ( current_chunk ) ;
507- }
500+ flush ( ) ;
508501
509502 parser . allow_whitespace ( ) ;
510503 const expression = read_expression ( parser ) ;
@@ -522,10 +515,11 @@ function read_sequence(parser: Parser, done: () => boolean): Node[] {
522515 start : parser . index ,
523516 end : null ,
524517 type : 'Text' ,
525- data : '' ,
518+ raw : '' ,
519+ data : null
526520 } ;
527521 } else {
528- current_chunk . data += parser . template [ parser . index ++ ] ;
522+ current_chunk . raw += parser . template [ parser . index ++ ] ;
529523 }
530524 }
531525
0 commit comments