mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
fix(core): SSR error in signal forms
Resolves an SSR error, because we weren't checking if `MutationObserver` is available.
(cherry picked from commit 3f80ae74ba)
This commit is contained in:
parent
0c27954a4d
commit
67fbd5ff1e
1 changed files with 10 additions and 2 deletions
|
|
@ -352,8 +352,16 @@ function listenToNativeControl(lView: LView<{} | null>, tNode: TNode, control:
|
|||
// This means that we need to know when an `<option>` is created, destroyed, or has its `value`
|
||||
// changed so that we can re-sync the `<select>` to the field state's value. We implement this
|
||||
// using a `MutationObserver` that we create to observe `<option>` changes.
|
||||
if (element instanceof HTMLSelectElement) {
|
||||
const observer = observeSelectMutations(element, getControlDirective(tNode, lView)!);
|
||||
if (
|
||||
tNode.type === TNodeType.Element &&
|
||||
tNode.value === 'select' &&
|
||||
typeof MutationObserver === 'function'
|
||||
) {
|
||||
const observer = observeSelectMutations(
|
||||
element as HTMLSelectElement,
|
||||
getControlDirective(tNode, lView)!,
|
||||
);
|
||||
|
||||
storeCleanupWithContext(tView, lView, observer, observer.disconnect);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue