File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed
packages/svelte/src/compiler/phases/1-parse Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -49,15 +49,14 @@ export class Parser {
4949
5050 this . template = template . trimRight ( ) ;
5151
52- const lang_matches = this . template . matchAll ( regex_lang_attribute ) ;
52+ let match_lang ;
5353
54- for ( const match of lang_matches ) {
55- if ( match [ 0 ] ?. [ 1 ] === 's' ) {
56- // ensure it starts with '<s' to match script tags
57- this . ts = match [ 2 ] === 'ts' ;
58- break ;
59- }
60- }
54+ do match_lang = regex_lang_attribute . exec ( template ) ;
55+ while ( match_lang && match_lang [ 0 ] [ 1 ] !== 's' ) ; // ensure it starts with '<s' to match script tags
56+
57+ regex_lang_attribute . lastIndex = 0 ; // need to reset index to pass tests — otherwise do not use global regex
58+
59+ this . ts = match_lang ?. [ 2 ] === 'ts' ;
6160
6261 this . root = {
6362 css : null ,
You can’t perform that action at this time.
0 commit comments