Skip to content

Commit

Permalink
fix: change == to ===
Browse files Browse the repository at this point in the history
  • Loading branch information
warmthsea committed May 14, 2024
1 parent 61ee26b commit b367691
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/components/focus-trap/src/focus-trap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export default defineComponent({
trapContainer.dispatchEvent(releasedEvent)
if (
!releasedEvent.defaultPrevented &&
(focusReason.value == 'keyboard' ||
(focusReason.value === 'keyboard' ||
!isFocusCausedByUserEvent() ||
trapContainer.contains(document.activeElement))
) {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/switch/__tests__/switch.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ describe('Switch.vue', () => {
return new Promise<boolean>((resolve, reject) => {
setTimeout(() => {
loading.value = false
return asyncResult.value == 'success'
return asyncResult.value === 'success'
? resolve(true)
: reject(new Error('Error'))
}, 1000)
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/__tests__/use-cursor.vitest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('useCursor', () => {
it('record and set cursor correctly', async () => {
const inputRef = shallowRef<HTMLInputElement>()
const [recordCursor, setCursor] = useCursor(inputRef)
if (inputRef.value == undefined) return
if (inputRef.value === undefined) return
inputRef.value.value = 'abc'
//set a cursor position
inputRef.value.setSelectionRange(1, 1)
Expand Down
12 changes: 6 additions & 6 deletions packages/hooks/use-cursor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export function useCursor(
}>()

function recordCursor() {
if (input.value == undefined) return
if (input.value === undefined) return

const { selectionStart, selectionEnd, value } = input.value

if (selectionStart == null || selectionEnd == null) return
if (selectionStart === null || selectionEnd === null) return

const beforeTxt = value.slice(0, Math.max(0, selectionStart))
const afterTxt = value.slice(Math.max(0, selectionEnd))
Expand All @@ -33,15 +33,15 @@ export function useCursor(
}
}
function setCursor() {
if (input.value == undefined || selectionRef.value == undefined) return
if (input.value === undefined || selectionRef.value === undefined) return

const { value } = input.value
const { beforeTxt, afterTxt, selectionStart } = selectionRef.value

if (
beforeTxt == undefined ||
afterTxt == undefined ||
selectionStart == undefined
beforeTxt === undefined ||
afterTxt === undefined ||
selectionStart === undefined
)
return

Expand Down

0 comments on commit b367691

Please sign in to comment.