]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
refactor(compiler-sfc): defineOptions avoid redundant conditional judgments (#9453)
authorSimon He <57086651+Simon-He95@users.noreply.github.com>
Mon, 27 May 2024 09:59:29 +0000 (17:59 +0800)
committerGitHub <noreply@github.com>
Mon, 27 May 2024 09:59:29 +0000 (17:59 +0800)
packages/compiler-sfc/src/script/defineOptions.ts

index 8e32e0fba82a8229257e7c3ffdbe1dc2ad5f2d20..0ab6de3080b46a115c743c9e80b6960a7c9c59c2 100644 (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
+        }
       }
     }
   }