Skip to content

Commit e1071f0

Browse files
crisbetojelbourn
authored andcommitted
fix(drag-drop): error on IE when customizing root element (#13279)
Fixes an error being thrown on IE when the root element is customized. The error comes from the fact that IE doesn't support `Element.prototype.matches`, but it does support `msMatchesSelector`.
1 parent 70dd33f commit e1071f0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/cdk/drag-drop/drag.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,10 +670,13 @@ export class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
670670
/** Gets the root draggable element, based on the `rootElementSelector`. */
671671
private _getRootElement(): HTMLElement {
672672
if (this.rootElementSelector) {
673+
const selector = this.rootElementSelector;
673674
let currentElement = this.element.nativeElement.parentElement as HTMLElement | null;
674675

675676
while (currentElement) {
676-
if (currentElement.matches(this.rootElementSelector)) {
677+
// IE doesn't support `matches` so we have to fall back to `msMatchesSelector`.
678+
if (currentElement.matches ? currentElement.matches(selector) :
679+
currentElement.msMatchesSelector(selector)) {
677680
return currentElement;
678681
}
679682

0 commit comments

Comments
 (0)