mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
fix(core): explicitly cast signal node value to String
If the computed's `toString` is called and `node.value` is a Symbol, the browser will throw an exception `ERROR TypeError: Cannot convert a Symbol value to a string`
Symbols cannot be implicitly changed to strings. This change changes the conversion to be explicit by wrapping `node.value` with `String()`
This can be reproduced if you create a computed with `createComputed(computation, equal)` and call `toString()` while `node.value` is something like `Symbol(UNSET)`
(cherry picked from commit e2a9938c51)
This commit is contained in:
parent
a8127273a6
commit
0edbee4550
3 changed files with 3 additions and 3 deletions
|
|
@ -84,7 +84,7 @@ export function createComputed<T>(
|
|||
(computed as ComputedGetter<T>)[SIGNAL] = node;
|
||||
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
||||
const debugName = node.debugName ? ' (' + node.debugName + ')' : '';
|
||||
computed.toString = () => `[Computed${debugName}: ${node.value}]`;
|
||||
computed.toString = () => `[Computed${debugName}: ${String(node.value)}]`;
|
||||
}
|
||||
|
||||
runPostProducerCreatedFn(node);
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ export function createLinkedSignal<S, D>(
|
|||
getter[SIGNAL] = node;
|
||||
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
||||
const debugName = node.debugName ? ' (' + node.debugName + ')' : '';
|
||||
getter.toString = () => `[LinkedSignal${debugName}: ${node.value}]`;
|
||||
getter.toString = () => `[LinkedSignal${debugName}: ${String(node.value)}]`;
|
||||
}
|
||||
|
||||
runPostProducerCreatedFn(node);
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ export function createSignal<T>(
|
|||
(getter as any)[SIGNAL] = node;
|
||||
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
||||
const debugName = node.debugName ? ' (' + node.debugName + ')' : '';
|
||||
getter.toString = () => `[Signal${debugName}: ${node.value}]`;
|
||||
getter.toString = () => `[Signal${debugName}: ${String(node.value)}]`;
|
||||
}
|
||||
|
||||
runPostProducerCreatedFn(node);
|
||||
|
|
|
|||
Loading…
Reference in a new issue