Skip to content

Commit

Permalink
fix: fix DND on IE11 (#3222)
Browse files Browse the repository at this point in the history
  • Loading branch information
JKMarkowski committed Sep 10, 2020
1 parent 03d8f09 commit ec4a785
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,15 @@ export class DndItemDirective implements AfterContentInit, OnDestroy {
/** @hidden */
private createPlaceHolder(): void {
/** Cloning container element */
const clone = this.element.nativeElement.cloneNode(true);

/** Taking cloned element reference */
this._placeholderElement = clone.firstChild.parentElement;
this._placeholderElement = this.element.nativeElement.cloneNode(true);

this._placeholderElement.classList.add('fd-dnd-placeholder');
this._setPlaceholderStyles();

/** Including element to the container */
this.element.nativeElement.after(clone);
/** Including element to the container
* IE11 equivalent to `this.element.nativeElement.after(clone);`
*/
this._placeAfter(this.element.nativeElement, this._placeholderElement);
}

/** @hidden */
Expand Down Expand Up @@ -252,4 +251,12 @@ export class DndItemDirective implements AfterContentInit, OnDestroy {
this._dragRef.started.subscribe(() => this.onCdkDragStart())
);
}

/** IE11 equivalent of Node.after() Method */
private _placeAfter(element: Element, cloneNode: Node): void {
const docFrag = document.createDocumentFragment();
docFrag.appendChild(cloneNode);
element.parentNode.insertBefore(docFrag, element.nextSibling)
}
}

0 comments on commit ec4a785

Please sign in to comment.