MCPcopy Index your code
hub / github.com/angular/angular / prepareForHydration

Function prepareForHydration

packages/platform-server/src/utils.ts:95–125  ·  view source on GitHub ↗

* Annotate nodes for hydration and remove event dispatch script when not needed.

(platformState: PlatformState, applicationRef: ApplicationRef)

Source from the content-addressed store, hash-verified

93 * Annotate nodes for hydration and remove event dispatch script when not needed.
94 */
95function prepareForHydration(platformState: PlatformState, applicationRef: ApplicationRef): void {
96 const measuringLabel = 'prepareForHydration';
97 startMeasuring(measuringLabel);
98 const environmentInjector = applicationRef.injector;
99 const doc = platformState.getDocument();
100
101 if (!environmentInjector.get(IS_HYDRATION_DOM_REUSE_ENABLED, false)) {
102 // Hydration is diabled, remove inlined event dispatch script.
103 // (which was injected by the build process) from the HTML.
104 removeEventDispatchScript(doc);
105
106 return;
107 }
108
109 appendSsrContentIntegrityMarker(doc);
110
111 const eventTypesToReplay = annotateForHydration(applicationRef, doc);
112 if (eventTypesToReplay.regular.size || eventTypesToReplay.capture.size) {
113 insertEventRecordScript(
114 environmentInjector.get(APP_ID),
115 doc,
116 eventTypesToReplay,
117 environmentInjector.get(CSP_NONCE, null),
118 );
119 } else {
120 // No events to replay, we should remove inlined event dispatch script
121 // (which was injected by the build process) from the HTML.
122 removeEventDispatchScript(doc);
123 }
124 stopMeasuring(measuringLabel);
125}
126
127/**
128 * Creates a marker comment node and append it into the `<body>`.

Callers 1

renderInternalFunction · 0.85

Calls 8

startMeasuringFunction · 0.85
annotateForHydrationFunction · 0.85
insertEventRecordScriptFunction · 0.85
stopMeasuringFunction · 0.85
getDocumentMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…