Skip to content

Commit 0106420

Browse files
authored
Revert "fix(material/form-field): outline label position (#29123)" (#29132)
This reverts commit eb22e2e.
1 parent eb22e2e commit 0106420

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/material/form-field/form-field.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88
import {Directionality} from '@angular/cdk/bidi';
9-
import {Platform, _getShadowRoot} from '@angular/cdk/platform';
9+
import {Platform} from '@angular/cdk/platform';
1010
import {
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
}

0 commit comments

Comments
 (0)