Files
angular/packages/platform-server
arturovt 551c446d98 fix(core): throw NG0502 instead of a TypeError when a hydration comment is missing
Consider the following template:

```html
<main>
  @if (show) {
    <span>text</span>
  }
</main>
```

During hydration, Angular looks for the comment node that marks where the
`@if` block (or an `<ng-container>`) is. If the HTML from the server was
changed and this comment is missing, dev mode throws a clear NG0502 error.
But this check only runs in dev mode.

Prior to this fix, production continued with the missing comment and failed
later with a raw error that doesn't say what went wrong:

```
TypeError: Cannot set properties of null (setting '__ngContext__')
```

With this fix, production also throws NG0502.
2026-11-12 09:25:51 -08:00
..
2024-03-28 13:02:50 -07:00