mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
4560f4fdcd
When hydration locates the DOM node for an ɵɵelementStart/ɵɵdomElementStart instruction, locateOrCreateElementNodeImpl assumed the located node was always an Element and called hasSkipHydrationAttrOnRElement(native), which does native.hasAttribute(...). The check that would normally catch this class of mismatch, validateMatchingNode, is gated behind `ngDevMode &&` and is compiled out of production builds. So when a real SSR/hydration structural mismatch located a Text or Comment node instead of the expected Element, production builds hit .hasAttribute on a node type that doesn't have it and crashed with a raw, uncoded TypeError instead of a coded hydration-mismatch RuntimeError. Add a cheap, always-on nodeType check ahead of that call. On mismatch it throws RuntimeError(HYDRATION_NODE_MISMATCH, ngDevMode && '...'), the same pattern used elsewhere in the codebase, so the descriptive message is only built in dev mode and production keeps throwing just the bare NG0500 code without pulling validateMatchingNode's DOM-printing machinery into the production bundle (verified via the bundling/hydration golden-symbols test, which is unchanged).