1
0
Эх сурвалжийг харах

fix(core): use startsWith instead of indexOf

Madjid Taha 2 жил өмнө
parent
commit
b4cf4d1636

+ 4 - 8
packages/tres/src/core/useInstanceCreator/index.ts

@@ -42,18 +42,14 @@ export function useInstanceCreator(prefix: string) {
         value = normalizeVectorFlexibleParam(value)
         value = normalizeVectorFlexibleParam(value)
       } else {
       } else {
         VECTOR3_PROPS.forEach(vecProps => {
         VECTOR3_PROPS.forEach(vecProps => {
-          // Check if the props contain one of the transform props
-          // and ensure it begin with it and then is followed only with the axis
-          if (
-            camelKey.includes(vecProps) &&
-            camelKey.indexOf(vecProps) === 0 &&
-            camelKey.length === vecProps.length + 1
-          ) {
+          // Check if the props starts with one of the transform props
+          // and is followed only with the axis
+          if (camelKey.startsWith(vecProps) && camelKey.length === vecProps.length + 1) {
             transformProps = vecProps
             transformProps = vecProps
             transformAxis = camelKey.substring(vecProps.length)
             transformAxis = camelKey.substring(vecProps.length)
             if (!VECTOR3_AXIS.includes(transformAxis)) {
             if (!VECTOR3_AXIS.includes(transformAxis)) {
               logError(
               logError(
-                `There was an error setting ${camelKey} property, ${transformAxis} is not a valid axis for ${transformProps}`,
+                `There was an error setting ${key} property, ${transformAxis} is not a valid axis for ${transformProps}`,
               )
               )
             }
             }
           }
           }