Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
textarea-caret: Improve performance of getCaretCoordinates.
Aman Agrawal04e6b4eb4eda
diff --git a/package.json b/package.jsonindex 04c8f678f25..c2a44ee65d9 100644--- a/package.json+++ b/package.json@@ -172,7 +172,8 @@"handlebars": "patches/handlebars.patch","[email protected]": "patches/[email protected]","svgicons2svgfont": "patches/svgicons2svgfont.patch",- "[email protected]": "patches/[email protected]"+ "[email protected]": "patches/[email protected]",+ "[email protected]": "patches/[email protected]"}},"nyc": {diff --git a/patches/[email protected] b/patches/[email protected]new file mode 100644index 00000000000..ceebb9a359a--- /dev/null+++ b/patches/[email protected]@@ -0,0 +1,20 @@+diff --git a/index.js b/index.js+index 0b06d12bb550fbf8043645a8d680817909cb2b04..c94bbcbf0e65ecf370195f6f3b03a2be62012d0c 100644+--- a/index.js++++ b/index.js+@@ -65,7 +65,6 @@ function getCaretCoordinates(element, position, options) {+ // The mirror div will replicate the textarea's style+ var div = document.createElement('div');+ div.id = 'input-textarea-caret-position-mirror-div';+- document.body.appendChild(div);++ var style = div.style;+ var computed = window.getComputedStyle ? window.getComputedStyle(element) : element.currentStyle; // currentStyle for IE < 9+@@ -113,6 +112,7 @@ function getCaretCoordinates(element, position, options) {+ // For inputs, just '.' would be enough, but no need to bother.+ span.textContent = element.value.substring(position) || '.'; // || because a completely empty faux span doesn't render at all+ div.appendChild(span);++ document.body.appendChild(div);++ var coordinates = {+ top: span.offsetTop + parseInt(computed['borderTopWidth']),diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 707c5c51920..8edf1cb9747 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -17,6 +17,9 @@ patchedDependencies:svgicons2svgfont:hash: d4mkid5oxxg6zfe7zsae2cikn4path: patches/svgicons2svgfont.patch+ hash: 4l2w4ru66ocl2j45eog5vet7ve+ path: patches/[email protected]hash: mlbmk5pq4q6iuwarqu6solgeeqpath: patches/[email protected]@@ -258,7 +261,7 @@ importers:version: 4.1.1textarea-caret:specifier: ^3.1.0- version: 3.1.0+ version: 3.1.0(patch_hash=4l2w4ru66ocl2j45eog5vet7ve)tippy.js:specifier: ^6.3.7version: 6.3.7(patch_hash=mlbmk5pq4q6iuwarqu6solgeeq)@@ -18586,7 +18589,7 @@ snapshots:- [email protected]: {}+ [email protected](patch_hash=4l2w4ru66ocl2j45eog5vet7ve): {}dependencies: