File tree 5 files changed +193
-3
lines changed
test/parser/samples/script-context-module-unquoted
5 files changed +193
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' svelte ' : patch
3
+ ---
4
+
5
+ fix: adjust static attribute regex
Original file line number Diff line number Diff line change @@ -437,7 +437,7 @@ function get_directive_type(name) {
437
437
if ( name === 'in' || name === 'out' || name === 'transition' ) return 'Transition' ;
438
438
}
439
439
440
- const regex_attribute_value = / ^ (?: " ( [ ^ " ] * ) " | ' ( [ ^ ' ] ) * ' | ( [ ^ > \s ] ) ) / ;
440
+ const regex_attribute_value = / ^ (?: " ( [ ^ " ] * ) " | ' ( [ ^ ' ] ) * ' | ( [ ^ > \s ] + ) ) / ;
441
441
442
442
/**
443
443
* @param {import('../index.js').Parser } parser
Original file line number Diff line number Diff line change @@ -253,9 +253,9 @@ function stringify_tag_attributes(attributes) {
253
253
}
254
254
255
255
const regex_style_tags =
256
- / < ! - - [ ^ ] * ?- - > | < s t y l e ( (?: \s + [ ^ = > ' " \/ ] + = (?: " [ ^ " ] * " | ' [ ^ ' ] * ' | [ ^ > \s ] ) | \s + [ ^ = > ' " \/ ] + ) * \s * ) (?: \/ > | > ( [ \S \s ] * ?) < \/ s t y l e > ) / g;
256
+ / < ! - - [ ^ ] * ?- - > | < s t y l e ( (?: \s + [ ^ = > ' " \/ ] + = (?: " [ ^ " ] * " | ' [ ^ ' ] * ' | [ ^ > \s ] + ) | \s + [ ^ = > ' " \/ ] + ) * \s * ) (?: \/ > | > ( [ \S \s ] * ?) < \/ s t y l e > ) / g;
257
257
const regex_script_tags =
258
- / < ! - - [ ^ ] * ?- - > | < s c r i p t ( (?: \s + [ ^ = > ' " \/ ] + = (?: " [ ^ " ] * " | ' [ ^ ' ] * ' | [ ^ > \s ] ) | \s + [ ^ = > ' " \/ ] + ) * \s * ) (?: \/ > | > ( [ \S \s ] * ?) < \/ s c r i p t > ) / g;
258
+ / < ! - - [ ^ ] * ?- - > | < s c r i p t ( (?: \s + [ ^ = > ' " \/ ] + = (?: " [ ^ " ] * " | ' [ ^ ' ] * ' | [ ^ > \s ] + ) | \s + [ ^ = > ' " \/ ] + ) * \s * ) (?: \/ > | > ( [ \S \s ] * ?) < \/ s c r i p t > ) / g;
259
259
260
260
/**
261
261
* Calculate the updates required to process all instances of the specified tag.
Original file line number Diff line number Diff line change
1
+ <script context =module >
2
+ export const foo = ' bar' ;
3
+ </script >
4
+
5
+ <script >
6
+ foo;
7
+ </script >
Original file line number Diff line number Diff line change
1
+ {
2
+ "html" : {
3
+ "start" : 62 ,
4
+ "end" : 60 ,
5
+ "type" : " Fragment" ,
6
+ "children" : [
7
+ {
8
+ "start" : 60 ,
9
+ "end" : 62 ,
10
+ "type" : " Text" ,
11
+ "raw" : " \n\n " ,
12
+ "data" : " \n\n "
13
+ }
14
+ ]
15
+ },
16
+ "instance" : {
17
+ "type" : " Script" ,
18
+ "start" : 62 ,
19
+ "end" : 86 ,
20
+ "context" : " default" ,
21
+ "content" : {
22
+ "type" : " Program" ,
23
+ "start" : 70 ,
24
+ "end" : 77 ,
25
+ "loc" : {
26
+ "start" : {
27
+ "line" : 1 ,
28
+ "column" : 0
29
+ },
30
+ "end" : {
31
+ "line" : 7 ,
32
+ "column" : 0
33
+ }
34
+ },
35
+ "body" : [
36
+ {
37
+ "type" : " ExpressionStatement" ,
38
+ "start" : 72 ,
39
+ "end" : 76 ,
40
+ "loc" : {
41
+ "start" : {
42
+ "line" : 6 ,
43
+ "column" : 1
44
+ },
45
+ "end" : {
46
+ "line" : 6 ,
47
+ "column" : 5
48
+ }
49
+ },
50
+ "expression" : {
51
+ "type" : " Identifier" ,
52
+ "start" : 72 ,
53
+ "end" : 75 ,
54
+ "loc" : {
55
+ "start" : {
56
+ "line" : 6 ,
57
+ "column" : 1
58
+ },
59
+ "end" : {
60
+ "line" : 6 ,
61
+ "column" : 4
62
+ }
63
+ },
64
+ "name" : " foo"
65
+ }
66
+ }
67
+ ],
68
+ "sourceType" : " module"
69
+ }
70
+ },
71
+ "module" : {
72
+ "type" : " Script" ,
73
+ "start" : 0 ,
74
+ "end" : 60 ,
75
+ "context" : " module" ,
76
+ "content" : {
77
+ "type" : " Program" ,
78
+ "start" : 23 ,
79
+ "end" : 51 ,
80
+ "loc" : {
81
+ "start" : {
82
+ "line" : 1 ,
83
+ "column" : 0
84
+ },
85
+ "end" : {
86
+ "line" : 3 ,
87
+ "column" : 0
88
+ }
89
+ },
90
+ "body" : [
91
+ {
92
+ "type" : " ExportNamedDeclaration" ,
93
+ "start" : 25 ,
94
+ "end" : 50 ,
95
+ "loc" : {
96
+ "start" : {
97
+ "line" : 2 ,
98
+ "column" : 1
99
+ },
100
+ "end" : {
101
+ "line" : 2 ,
102
+ "column" : 26
103
+ }
104
+ },
105
+ "declaration" : {
106
+ "type" : " VariableDeclaration" ,
107
+ "start" : 32 ,
108
+ "end" : 50 ,
109
+ "loc" : {
110
+ "start" : {
111
+ "line" : 2 ,
112
+ "column" : 8
113
+ },
114
+ "end" : {
115
+ "line" : 2 ,
116
+ "column" : 26
117
+ }
118
+ },
119
+ "declarations" : [
120
+ {
121
+ "type" : " VariableDeclarator" ,
122
+ "start" : 38 ,
123
+ "end" : 49 ,
124
+ "loc" : {
125
+ "start" : {
126
+ "line" : 2 ,
127
+ "column" : 14
128
+ },
129
+ "end" : {
130
+ "line" : 2 ,
131
+ "column" : 25
132
+ }
133
+ },
134
+ "id" : {
135
+ "type" : " Identifier" ,
136
+ "start" : 38 ,
137
+ "end" : 41 ,
138
+ "loc" : {
139
+ "start" : {
140
+ "line" : 2 ,
141
+ "column" : 14
142
+ },
143
+ "end" : {
144
+ "line" : 2 ,
145
+ "column" : 17
146
+ }
147
+ },
148
+ "name" : " foo"
149
+ },
150
+ "init" : {
151
+ "type" : " Literal" ,
152
+ "start" : 44 ,
153
+ "end" : 49 ,
154
+ "loc" : {
155
+ "start" : {
156
+ "line" : 2 ,
157
+ "column" : 20
158
+ },
159
+ "end" : {
160
+ "line" : 2 ,
161
+ "column" : 25
162
+ }
163
+ },
164
+ "value" : " bar" ,
165
+ "raw" : " 'bar'"
166
+ }
167
+ }
168
+ ],
169
+ "kind" : " const"
170
+ },
171
+ "specifiers" : [],
172
+ "source" : null
173
+ }
174
+ ],
175
+ "sourceType" : " module"
176
+ }
177
+ }
178
+ }
You can’t perform that action at this time.
0 commit comments