Skip to content

Commit 054ccec

Browse files
authored
perf(core): use startsWith instead of indexOf (#989)
1 parent 9e26be2 commit 054ccec

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

packages/runtime-core/src/componentEmits.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function emit(
7373
let handler = props[`on${capitalize(event)}`]
7474
// for v-model update:xxx events, also trigger kebab-case equivalent
7575
// for props passed via kebab-case
76-
if (!handler && event.indexOf('update:') === 0) {
76+
if (!handler && event.startsWith('update:')) {
7777
event = hyphenate(event)
7878
handler = props[`on${capitalize(event)}`]
7979
}

packages/runtime-dom/src/modules/attrs.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function patchAttr(
88
value: any,
99
isSVG: boolean
1010
) {
11-
if (isSVG && key.indexOf('xlink:') === 0) {
11+
if (isSVG && key.startsWith('xlink:')) {
1212
if (value == null) {
1313
el.removeAttributeNS(xlinkNS, key.slice(6, key.length))
1414
} else {

packages/runtime-dom/src/patchProp.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const patchProp: RendererOptions<Node, Element>['patchProp'] = (
3030
default:
3131
if (isOn(key)) {
3232
// ignore v-model listeners
33-
if (key.indexOf('onUpdate:') < 0) {
33+
if (!key.startsWith('onUpdate:')) {
3434
patchEvent(el, key, prevValue, nextValue, parentComponent)
3535
}
3636
} else if (

packages/shared/src/normalizeProp.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function stringifyStyle(
2929
}
3030
for (const key in styles) {
3131
const value = styles[key]
32-
const normalizedKey = key.indexOf(`--`) === 0 ? key : hyphenate(key)
32+
const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key)
3333
if (
3434
isString(value) ||
3535
(typeof value === 'number' && isNoUnitNumericStyleProp(normalizedKey))

0 commit comments

Comments
 (0)