MCPcopy Create free account
hub / github.com/angular/components / _updateDocument

Method _updateDocument

docs/src/app/shared/doc-viewer/doc-viewer.ts:155–184  ·  view source on GitHub ↗

* Updates the displayed document. * @param rawDocument The raw document content to show.

(rawDocument: string)

Source from the content-addressed store, hash-verified

153 * @param rawDocument The raw document content to show.
154 */
155 private _updateDocument(rawDocument: string) {
156 // Replace all relative fragment URLs with absolute fragment URLs. e.g. "#my-section" becomes
157 // "/components/button/api#my-section". This is necessary because otherwise these fragment
158 // links would redirect to "/#my-section".
159 rawDocument = rawDocument.replace(/href="#([^"]*)"/g, (_m: string, fragmentUrl: string) => {
160 const absoluteUrl = `${location.pathname}#${fragmentUrl}`;
161 return `href="${this._domSanitizer.sanitize(SecurityContext.URL, absoluteUrl)}"`;
162 });
163 this._elementRef.nativeElement.innerHTML = rawDocument;
164 this.textContent = this._elementRef.nativeElement.textContent;
165 this._loadComponents('material-docs-example', ExampleViewer);
166 this._loadComponents('header-link', HeaderLink);
167
168 // Inject Angular Aria banner for specific CDK components
169 this._injectAngularAriaBanner();
170
171 // Create tooltips for the deprecated fields
172 this._createTooltipsForDeprecated();
173
174 // Create icon buttons to copy module import
175 this._createCopyIconForModule();
176
177 // Resolving and creating components dynamically in Angular happens synchronously, but since
178 // we want to emit the output if the components are actually rendered completely, we wait
179 // until the Angular zone becomes stable.
180 // tslint:disable-next-line:no-zone-dependencies
181 this._ngZone.onStable
182 .pipe(take(1))
183 .subscribe(() => this.contentRendered.next(this._elementRef.nativeElement));
184 }
185
186 /** Show an error that occurred when fetching a document. */
187 private _showError(url: string, error: HttpErrorResponse) {

Callers 1

_fetchDocumentMethod · 0.95

Calls 5

_loadComponentsMethod · 0.95
nextMethod · 0.45

Tested by

no test coverage detected