pull/18650/merge
asphum 5 days ago committed by GitHub
commit ada2884d22
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,9 @@
---
'svelte': patch
---
fix: coerce symbols to empty string in `set_text`
Under `experimental.async`, `$bindable` props can briefly surface `Symbol(UNINITIALIZED)`.
`set_text` treated symbols as already-stringifiable values, then threw when assigning
`text.nodeValue = \`${str}\``. Treat symbols like nullish values so text nodes stay stable.

@ -45,7 +45,7 @@ export function set_should_intro(value) {
*/ */
export function set_text(text, value) { export function set_text(text, value) {
// For objects, we apply string coercion (which might make things like $state array references in the template reactive) before diffing // For objects, we apply string coercion (which might make things like $state array references in the template reactive) before diffing
var str = value == null ? '' : typeof value === 'object' ? `${value}` : value; var str = value == null || typeof value === 'symbol' ? '' : typeof value === 'object' ? `${value}` : value;
// prettier-ignore // prettier-ignore
if (str !== (/** @type {any} */ (text)[TEXT_CACHE] ??= text.nodeValue)) { if (str !== (/** @type {any} */ (text)[TEXT_CACHE] ??= text.nodeValue)) {
/** @type {any} */ (text)[TEXT_CACHE] = str; /** @type {any} */ (text)[TEXT_CACHE] = str;

Loading…
Cancel
Save