File tree Expand file tree Collapse file tree 3 files changed +14
-1
lines changed
packages/svelte/src/compiler/phases/1-parse Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ export function parse(source, typescript) {
29
29
* @param {string } source
30
30
* @param {boolean } typescript
31
31
* @param {number } index
32
+ * @returns {acorn.Expression & { leadingComments?: CommentWithLocation[]; trailingComments?: CommentWithLocation[]; } }
32
33
*/
33
34
export function parse_expression_at ( source , typescript , index ) {
34
35
const parser = typescript ? ParserWithTS : acorn . Parser ;
@@ -110,6 +111,9 @@ function get_comment_handlers(source) {
110
111
}
111
112
}
112
113
} ) ;
114
+ if ( comments . length > 0 ) {
115
+ ( ast . trailingComments ||= [ ] ) . push ( ...comments . splice ( 0 ) )
116
+ }
113
117
}
114
118
} ;
115
119
}
Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ export default function read_expression(parser) {
17
17
}
18
18
19
19
let index = /** @type {number } */ ( node . end ) ;
20
+ if ( node . trailingComments !== undefined && node . trailingComments . length > 0 ) {
21
+ index = node . trailingComments . at ( - 1 ) . end ;
22
+ }
23
+
20
24
while ( num_parens > 0 ) {
21
25
const char = parser . template [ index ] ;
22
26
Original file line number Diff line number Diff line change @@ -14,9 +14,14 @@ export default function mustache(parser) {
14
14
parser . allow_whitespace ( ) ;
15
15
16
16
if ( parser . eat ( '#' ) ) return open ( parser ) ;
17
- if ( parser . eat ( '/' ) ) return close ( parser ) ;
18
17
if ( parser . eat ( ':' ) ) return next ( parser ) ;
19
18
if ( parser . eat ( '@' ) ) return special ( parser ) ;
19
+ if ( parser . match ( '/' ) ) {
20
+ if ( ! parser . match ( '/*' ) && ! parser . match ( '//' ) ) {
21
+ parser . eat ( '/' ) ;
22
+ return close ( parser ) ;
23
+ }
24
+ }
20
25
21
26
const expression = read_expression ( parser ) ;
22
27
You can’t perform that action at this time.
0 commit comments