Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: includes instead of indexOf #5117

Merged
merged 1 commit into from Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/compiler-core/src/parse.ts
Expand Up @@ -1044,7 +1044,7 @@ function parseTextData(
if (
mode === TextModes.RAWTEXT ||
mode === TextModes.CDATA ||
rawText.indexOf('&') === -1
!rawText.includes('&')
) {
return rawText
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-core/src/compat/renderHelpers.ts
Expand Up @@ -157,7 +157,7 @@ export function legacyCheckKeyCodes(

function isKeyNotMatch<T>(expect: T | T[], actual: T): boolean {
if (isArray(expect)) {
return expect.indexOf(actual) === -1
return !expect.includes(actual)
} else {
return expect !== actual
}
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-core/src/components/KeepAlive.ts
Expand Up @@ -345,7 +345,7 @@ function matches(pattern: MatchPattern, name: string): boolean {
if (isArray(pattern)) {
return pattern.some((p: string | RegExp) => matches(p, name))
} else if (isString(pattern)) {
return pattern.split(',').indexOf(name) > -1
return pattern.split(',').includes(name)
} else if (pattern.test) {
return pattern.test(name)
}
Expand Down
8 changes: 4 additions & 4 deletions scripts/setupJestEnv.ts
@@ -1,7 +1,7 @@
expect.extend({
toHaveBeenWarned(received: string) {
asserted.add(received)
const passed = warn.mock.calls.some(args => args[0].indexOf(received) > -1)
const passed = warn.mock.calls.some(args => args[0].includes(received))
if (passed) {
return {
pass: true,
Expand All @@ -23,7 +23,7 @@ expect.extend({
toHaveBeenWarnedLast(received: string) {
asserted.add(received)
const passed =
warn.mock.calls[warn.mock.calls.length - 1][0].indexOf(received) > -1
warn.mock.calls[warn.mock.calls.length - 1][0].includes(received)
if (passed) {
return {
pass: true,
Expand All @@ -43,7 +43,7 @@ expect.extend({
asserted.add(received)
let found = 0
warn.mock.calls.forEach(args => {
if (args[0].indexOf(received) > -1) {
if (args[0].includes(received)) {
found++
}
})
Expand Down Expand Up @@ -78,7 +78,7 @@ afterEach(() => {
.map(args => args[0])
.filter(received => {
return !assertedArray.some(assertedMsg => {
return received.indexOf(assertedMsg) > -1
return received.includes(assertedMsg)
})
})
warn.mockRestore()
Expand Down