File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
packages/compiler-sfc/src Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ export interface SFCParseOptions {
22
22
pad ?: boolean | 'line' | 'space'
23
23
ignoreEmpty ?: boolean
24
24
compiler ?: TemplateCompiler
25
+
26
+ defaultScriptLang ?: string
27
+ defaultScriptSetupLang ?: string
25
28
}
26
29
27
30
export interface SFCBlock {
@@ -95,7 +98,9 @@ export function parse(
95
98
sourceRoot = '' ,
96
99
pad = false ,
97
100
ignoreEmpty = true ,
98
- compiler = CompilerDOM
101
+ compiler = CompilerDOM ,
102
+ defaultScriptLang,
103
+ defaultScriptSetupLang
99
104
} : SFCParseOptions = { }
100
105
) : SFCParseResult {
101
106
const sourceKey =
@@ -190,6 +195,14 @@ export function parse(
190
195
case 'script' :
191
196
const scriptBlock = createBlock ( node , source , pad ) as SFCScriptBlock
192
197
const isSetup = ! ! scriptBlock . attrs . setup
198
+ if ( isSetup && defaultScriptSetupLang ) {
199
+ scriptBlock . lang ??= defaultScriptSetupLang
200
+ }
201
+
202
+ if ( defaultScriptLang ) {
203
+ scriptBlock . lang ??= defaultScriptLang
204
+ }
205
+
193
206
if ( isSetup && ! descriptor . scriptSetup ) {
194
207
descriptor . scriptSetup = scriptBlock
195
208
break
You can’t perform that action at this time.
0 commit comments