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 6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
import { Directionality } from '@angular/cdk/bidi' ;
9
- import { Platform , _getShadowRoot } from '@angular/cdk/platform' ;
9
+ import { Platform } from '@angular/cdk/platform' ;
10
10
import {
11
11
AfterContentChecked ,
12
12
AfterContentInit ,
@@ -701,13 +701,14 @@ export class MatFormField
701
701
/** Checks whether the form field is attached to the DOM. */
702
702
private _isAttachedToDom ( ) : boolean {
703
703
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 ) ;
712
713
}
713
714
}
You can’t perform that action at this time.
0 commit comments