Skip to content

Commit fa96995

Browse files
authored
Use nullish coalescing operator
1 parent 2c41036 commit fa96995

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/text.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export function insertText(textarea: HTMLInputElement | HTMLTextAreaElement, text: string): void {
2-
const before = textarea.value.slice(0, textarea.selectionStart || undefined)
3-
const after = textarea.value.slice(textarea.selectionEnd || undefined)
2+
const before = textarea.value.slice(0, textarea.selectionStart ?? undefined)
3+
const after = textarea.value.slice(textarea.selectionEnd ?? undefined)
44

55
let canInsertText = true
66

@@ -12,7 +12,7 @@ export function insertText(textarea: HTMLInputElement | HTMLTextAreaElement, tex
1212
}
1313
textarea.contentEditable = 'false'
1414

15-
if (canInsertText && !textarea.value.slice(0, textarea.selectionStart || undefined).endsWith(text)) {
15+
if (canInsertText && !textarea.value.slice(0, textarea.selectionStart ?? undefined).endsWith(text)) {
1616
canInsertText = false
1717
}
1818

0 commit comments

Comments
 (0)