MCPcopy
hub / github.com/angular/angular / hydrate

Function hydrate

packages/platform-server/test/dom_utils.ts:94–120  ·  view source on GitHub ↗
(
  doc: Document,
  component: Type<unknown>,
  options: {
    envProviders?: Provider[];
    hydrationFeatures?: () => HydrationFeature<HydrationFeatureKind>[];
  } = {},
)

Source from the content-addressed store, hash-verified

92}
93
94export function hydrate(
95 doc: Document,
96 component: Type<unknown>,
97 options: {
98 envProviders?: Provider[];
99 hydrationFeatures?: () => HydrationFeature<HydrationFeatureKind>[];
100 } = {},
101) {
102 const {envProviders = [], hydrationFeatures = () => []} = options;
103
104 // Apply correct reference to the `document` object,
105 // which will be used by runtime.
106 ɵsetDocument(doc);
107
108 // Define `document` to make `DefaultDomRenderer2` work, since it
109 // references `document` directly to create style tags.
110 global.document = doc;
111
112 const providers = [
113 {provide: PLATFORM_ID, useValue: 'browser'},
114 {provide: DOCUMENT, useFactory: () => doc},
115 provideClientHydration(...hydrationFeatures()),
116 ...envProviders,
117 ];
118
119 return bootstrapApplication(component, {providers});
120}
121
122export function insertDomInDocument(doc: Document, html: string) {
123 // Get HTML contents of the `<app>`, create a DOM element and append it into the body.

Callers 2

Calls 3

provideClientHydrationFunction · 0.90
bootstrapApplicationFunction · 0.90
hydrationFeaturesFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…