Skip to content

Commit 5a05324

Browse files
committed
Refactor
1 parent 68b447e commit 5a05324

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/selection.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { refKey } from "./utils";
1+
import { min, refKey } from "./utils";
22

33
/**
44
* @internal
@@ -41,15 +41,15 @@ export const initSelectionStore = (
4141
const pos = el.selectionStart!;
4242
if (!compositionEvent) return pos;
4343
// compensate selection range during compositioning
44-
return Math.min(pos, el.selectionEnd! - compositionEvent.data.length);
44+
return min(pos, el.selectionEnd! - compositionEvent.data.length);
4545
},
4646
_getSelectionEnd(): number {
4747
const el = ref[refKey];
4848
if (!el) return 0;
4949
const pos = el.selectionEnd!;
5050
// compensate selection range during compositioning
5151
if (!compositionEvent) return pos;
52-
return Math.min(pos, el.selectionStart! + compositionEvent.data.length);
52+
return min(pos, el.selectionStart! + compositionEvent.data.length);
5353
},
5454
};
5555
return handle;

src/utils.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* @internal
3+
*/
4+
export const { min } = Math;
5+
16
/**
27
* @internal
38
*/

0 commit comments

Comments
 (0)