web: Use util.the for accessing element of single-item lists.

This commit is contained in:
evykassirer
2024-08-19 22:18:02 -07:00
committed by Tim Abbott
parent 113de14547
commit d9f25d01a1
47 changed files with 188 additions and 140 deletions

View File

@@ -123,9 +123,9 @@ export function insert_and_scroll_into_view(
// to support `undo`, we can use a faster method.
$textarea.val(content);
} else if (replace_all) {
setFieldText($textarea[0]!, content);
setFieldText(util.the($textarea), content);
} else {
insertTextIntoField($textarea[0]!, content);
insertTextIntoField(util.the($textarea), content);
}
// Blurring and refocusing ensures the cursor / selection is in view
// in chromium browsers.
@@ -300,7 +300,7 @@ export function replace_syntax(
// for details.
const old_text = $textarea.val();
replaceFieldText($textarea[0]!, old_syntax, () => new_syntax, "after-replacement");
replaceFieldText(util.the($textarea), old_syntax, () => new_syntax, "after-replacement");
const new_text = $textarea.val();
// When replacing content in a textarea, we need to move the cursor