From e1071f03fa512a4afcd0058ee905dd2cbcb8b6e3 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Tue, 25 Sep 2018 16:06:59 +0200 Subject: [PATCH] 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`. --- src/cdk/drag-drop/drag.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cdk/drag-drop/drag.ts b/src/cdk/drag-drop/drag.ts index 9b96fc065bf..a3bf0c813e3 100644 --- a/src/cdk/drag-drop/drag.ts +++ b/src/cdk/drag-drop/drag.ts @@ -670,10 +670,13 @@ export class CdkDrag implements AfterViewInit, OnDestroy { /** Gets the root draggable element, based on the `rootElementSelector`. */ private _getRootElement(): HTMLElement { if (this.rootElementSelector) { + const selector = this.rootElementSelector; let currentElement = this.element.nativeElement.parentElement as HTMLElement | null; while (currentElement) { - if (currentElement.matches(this.rootElementSelector)) { + // IE doesn't support `matches` so we have to fall back to `msMatchesSelector`. + if (currentElement.matches ? currentElement.matches(selector) : + currentElement.msMatchesSelector(selector)) { return currentElement; }