* Callback for when the MutationObserver detects that the content has changed.
()
| 360 | * Callback for when the MutationObserver detects that the content has changed. |
| 361 | */ |
| 362 | _onContentChanges() { |
| 363 | const textContent = this._elementRef.nativeElement.textContent; |
| 364 | |
| 365 | // We need to diff the text content of the header, because the MutationObserver callback |
| 366 | // will fire even if the text content didn't change which is inefficient and is prone |
| 367 | // to infinite loops if a poorly constructed expression is passed in (see #14249). |
| 368 | if (textContent !== this._currentTextContent) { |
| 369 | this._currentTextContent = textContent || ''; |
| 370 | |
| 371 | // The content observer runs outside the `NgZone` by default, which |
| 372 | // means that we need to bring the callback back in ourselves. |
| 373 | this._ngZone.run(() => { |
| 374 | this.updatePagination(); |
| 375 | this._alignInkBarToSelectedTab(); |
| 376 | this._changeDetectorRef.markForCheck(); |
| 377 | }); |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | /** |
| 382 | * Updates the view whether pagination should be enabled or not. |
nothing calls this directly
no test coverage detected