Skip to content

Commit 63210fe

Browse files
authored
refactor: includes instead of indexOf (#5117)
1 parent c64907d commit 63210fe

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

packages/compiler-core/src/parse.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ function parseTextData(
10441044
if (
10451045
mode === TextModes.RAWTEXT ||
10461046
mode === TextModes.CDATA ||
1047-
rawText.indexOf('&') === -1
1047+
!rawText.includes('&')
10481048
) {
10491049
return rawText
10501050
} else {

packages/runtime-core/src/compat/renderHelpers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export function legacyCheckKeyCodes(
157157

158158
function isKeyNotMatch<T>(expect: T | T[], actual: T): boolean {
159159
if (isArray(expect)) {
160-
return expect.indexOf(actual) === -1
160+
return !expect.includes(actual)
161161
} else {
162162
return expect !== actual
163163
}

packages/runtime-core/src/components/KeepAlive.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ function matches(pattern: MatchPattern, name: string): boolean {
345345
if (isArray(pattern)) {
346346
return pattern.some((p: string | RegExp) => matches(p, name))
347347
} else if (isString(pattern)) {
348-
return pattern.split(',').indexOf(name) > -1
348+
return pattern.split(',').includes(name)
349349
} else if (pattern.test) {
350350
return pattern.test(name)
351351
}

scripts/setupJestEnv.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
expect.extend({
22
toHaveBeenWarned(received: string) {
33
asserted.add(received)
4-
const passed = warn.mock.calls.some(args => args[0].indexOf(received) > -1)
4+
const passed = warn.mock.calls.some(args => args[0].includes(received))
55
if (passed) {
66
return {
77
pass: true,
@@ -23,7 +23,7 @@ expect.extend({
2323
toHaveBeenWarnedLast(received: string) {
2424
asserted.add(received)
2525
const passed =
26-
warn.mock.calls[warn.mock.calls.length - 1][0].indexOf(received) > -1
26+
warn.mock.calls[warn.mock.calls.length - 1][0].includes(received)
2727
if (passed) {
2828
return {
2929
pass: true,
@@ -43,7 +43,7 @@ expect.extend({
4343
asserted.add(received)
4444
let found = 0
4545
warn.mock.calls.forEach(args => {
46-
if (args[0].indexOf(received) > -1) {
46+
if (args[0].includes(received)) {
4747
found++
4848
}
4949
})
@@ -78,7 +78,7 @@ afterEach(() => {
7878
.map(args => args[0])
7979
.filter(received => {
8080
return !assertedArray.some(assertedMsg => {
81-
return received.indexOf(assertedMsg) > -1
81+
return received.includes(assertedMsg)
8282
})
8383
})
8484
warn.mockRestore()

0 commit comments

Comments
 (0)