Skip to content

Commit 05036f1

Browse files
authored
🤖 Merge PR DefinitelyTyped#72414 fix(textarea-caret): Fix global name attached to window by @joeyparrish
1 parent 9af7928 commit 05036f1

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

‎types/textarea-caret/index.d.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export = textarea_caret;
1+
export = getCaretCoordinates;
22

33
interface Caret {
44
top: number;
@@ -10,4 +10,6 @@ interface Options {
1010
debug?: boolean | undefined;
1111
}
1212

13-
declare function textarea_caret(element: HTMLElement, position: number, options?: Options): Caret;
13+
declare function getCaretCoordinates(element: HTMLElement, position: number, options?: Options): Caret;
14+
15+
export as namespace getCaretCoordinates;
Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
import getCaretCoordinates = require("textarea-caret");
1+
import anyNameYouLike = require("textarea-caret");
22

33
const element = document.querySelector("textarea");
44

5-
element!.addEventListener("input", function() {
6-
const caret = getCaretCoordinates(this, this.selectionEnd);
7-
console.log("(top, left, height) = (%s, %s, %s)", caret.top, caret.left, caret.height);
8-
});
5+
function testImportedLibrary() {
6+
element!.addEventListener("input", function() {
7+
const caret = anyNameYouLike(this, this.selectionEnd);
8+
console.log("(top, left, height) = (%s, %s, %s)", caret.top, caret.left, caret.height);
9+
});
10+
}
11+
12+
function testGlobalName() {
13+
element!.addEventListener("input", function() {
14+
const caret = window.getCaretCoordinates(this, this.selectionEnd);
15+
console.log("(top, left, height) = (%s, %s, %s)", caret.top, caret.left, caret.height);
16+
});
17+
}

0 commit comments

Comments
 (0)