File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change 66 * found in the LICENSE file at https://angular.io/license
77 */
88import { Directionality } from '@angular/cdk/bidi' ;
9- import { Platform , _getShadowRoot } from '@angular/cdk/platform' ;
9+ import { Platform } from '@angular/cdk/platform' ;
1010import {
1111 AfterContentChecked ,
1212 AfterContentInit ,
@@ -701,13 +701,14 @@ export class MatFormField
701701 /** Checks whether the form field is attached to the DOM. */
702702 private _isAttachedToDom ( ) : boolean {
703703 const element : HTMLElement = this . _elementRef . nativeElement ;
704- const rootNode = element . getRootNode ( ) ;
705- // If the element is inside the DOM the root node will be either the document,
706- // the closest shadow root or an element that is not yet rendered, otherwise it'll be the element itself.
707- return (
708- rootNode &&
709- rootNode !== element &&
710- ( rootNode === document || rootNode === _getShadowRoot ( element ) )
711- ) ;
704+ if ( element . getRootNode ) {
705+ const rootNode = element . getRootNode ( ) ;
706+ // If the element is inside the DOM the root node will be either the document
707+ // or the closest shadow root, otherwise it'll be the element itself.
708+ return rootNode && rootNode !== element ;
709+ }
710+ // Otherwise fall back to checking if it's in the document. This doesn't account for
711+ // shadow DOM, however browser that support shadow DOM should support `getRootNode` as well.
712+ return document . documentElement ! . contains ( element ) ;
712713 }
713714}
You can’t perform that action at this time.
0 commit comments