]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
perf(core): use `startsWith` instead of `indexOf` (#989)
authorAndrew Talbot <andrew.talbot@richmond.edu>
Mon, 20 Apr 2020 19:44:20 +0000 (15:44 -0400)
committerGitHub <noreply@github.com>
Mon, 20 Apr 2020 19:44:20 +0000 (15:44 -0400)
packages/runtime-core/src/componentEmits.ts
packages/runtime-dom/src/modules/attrs.ts
packages/runtime-dom/src/patchProp.ts
packages/shared/src/normalizeProp.ts

index 228991b51d0bdddb69d04d93f8c981f915b29150..7b91bf3469228b6e9815c5e130d11596477ca0bf 100644 (file)
@@ -73,7 +73,7 @@ export function emit(
   let handler = props[`on${capitalize(event)}`]
   // for v-model update:xxx events, also trigger kebab-case equivalent
   // for props passed via kebab-case
-  if (!handler && event.indexOf('update:') === 0) {
+  if (!handler && event.startsWith('update:')) {
     event = hyphenate(event)
     handler = props[`on${capitalize(event)}`]
   }
index 10fe06afb7a5a43232a38d237f43d0f98fe806f7..b9bba846b0d3a0aae069d4abc1c3427cde6deab4 100644 (file)
@@ -8,7 +8,7 @@ export function patchAttr(
   value: any,
   isSVG: boolean
 ) {
-  if (isSVG && key.indexOf('xlink:') === 0) {
+  if (isSVG && key.startsWith('xlink:')) {
     if (value == null) {
       el.removeAttributeNS(xlinkNS, key.slice(6, key.length))
     } else {
index 4543bd1a54d8aa555246cc54c3d27a5c34a35b46..979f9f2427dcca8d792fd3a8cdbebf28888e4277 100644 (file)
@@ -30,7 +30,7 @@ export const patchProp: RendererOptions<Node, Element>['patchProp'] = (
     default:
       if (isOn(key)) {
         // ignore v-model listeners
-        if (key.indexOf('onUpdate:') < 0) {
+        if (!key.startsWith('onUpdate:')) {
           patchEvent(el, key, prevValue, nextValue, parentComponent)
         }
       } else if (
index 201e49806d3c15dbb90dee0282ad0d2fb6d17d22..77357c681a8c27478a1986f3e8b5e29b49e18d18 100644 (file)
@@ -29,7 +29,7 @@ export function stringifyStyle(
   }
   for (const key in styles) {
     const value = styles[key]
-    const normalizedKey = key.indexOf(`--`) === 0 ? key : hyphenate(key)
+    const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key)
     if (
       isString(value) ||
       (typeof value === 'number' && isNoUnitNumericStyleProp(normalizedKey))