global: Specialize jQuery .val() for elements with known value types.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2023-09-22 14:25:08 -07:00
committed by Tim Abbott
parent 06e8d1fb16
commit eefd7feafa
2 changed files with 16 additions and 4 deletions

View File

@@ -1,5 +1,4 @@
import _ from "lodash";
import assert from "minimalistic-assert";
// How to determine the direction of a paragraph (P1-P3): https://www.unicode.org/reports/tr9/tr9-35.html#The_Paragraph_Level
// Embedding level: https://www.unicode.org/reports/tr9/tr9-35.html#BD2
@@ -142,8 +141,7 @@ export function get_direction(str: string): "ltr" | "rtl" {
export function set_rtl_class_for_textarea($textarea: JQuery<HTMLTextAreaElement>): void {
// Set the rtl class if the text has an rtl direction, remove it otherwise
let text = $textarea.val();
assert(typeof text === "string", "Passed HTML element must be a textarea.");
let text = $textarea.val()!;
if (text.startsWith("```quote")) {
text = text.slice(8);
}