Skip to content

Commit

Permalink
perf(core): use startsWith instead of indexOf (#989)
Browse files Browse the repository at this point in the history
  • Loading branch information
aztalbot authored Apr 20, 2020
1 parent 9e26be2 commit 054ccec
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/runtime-core/src/componentEmits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`]
}
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-dom/src/modules/attrs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-dom/src/patchProp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/normalizeProp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 054ccec

Please sign in to comment.