* Updates the displayed document. * @param rawDocument The raw document content to show.
(rawDocument: string)
| 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) { |
no test coverage detected