mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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`.
This commit is contained in:
committed by
Jeremy Elbourn
parent
70dd33f143
commit
e1071f03fa
@@ -670,10 +670,13 @@ export class CdkDrag<T = any> 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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user