From adcceb4acaece8ec811fc6c8c815047302c767d7 Mon Sep 17 00:00:00 2001 From: Dominic Gannaway Date: Tue, 13 Aug 2024 15:43:14 +0100 Subject: [PATCH] chore: improve set_text perf (#12823) * chore: improve set_text perf * chore: improve set_text perf * chore: improve set_text perf * chore: improve set_text perf --- packages/svelte/src/internal/client/render.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/svelte/src/internal/client/render.js b/packages/svelte/src/internal/client/render.js index 3cc2771e33..c991023325 100644 --- a/packages/svelte/src/internal/client/render.js +++ b/packages/svelte/src/internal/client/render.js @@ -47,7 +47,9 @@ export function set_text(text, value) { if (prev !== value) { // @ts-expect-error - text.nodeValue = text.__t = value; + text.__t = value; + // It's faster to make the value a string rather than passing a non-string to nodeValue + text.nodeValue = value == null ? '' : value + ''; } }