refactor(compiler-sfc): defineOptions avoid redundant conditional judgments (#9453)

This commit is contained in:
Simon He 2024-05-27 17:59:29 +08:00 committed by GitHub
parent baa656ee41
commit 56f5692fb6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 4 deletions

View File

@ -37,10 +37,23 @@ export function processDefineOptions(
(prop.type === 'ObjectProperty' || prop.type === 'ObjectMethod') &&
prop.key.type === 'Identifier'
) {
if (prop.key.name === 'props') propsOption = prop
if (prop.key.name === 'emits') emitsOption = prop
if (prop.key.name === 'expose') exposeOption = prop
if (prop.key.name === 'slots') slotsOption = prop
switch (prop.key.name) {
case 'props':
propsOption = prop
break
case 'emits':
emitsOption = prop
break
case 'expose':
exposeOption = prop
break
case 'slots':
slotsOption = prop
break
}
}
}
}