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

Method _updateDocument

docs/src/app/shared/doc-viewer/doc-viewer.ts:148–177  ·  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

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