diff --git a/src/cdk/drag-drop/directives/drag.spec.ts b/src/cdk/drag-drop/directives/drag.spec.ts index 97077253ebe3..6534c56828b1 100644 --- a/src/cdk/drag-drop/directives/drag.spec.ts +++ b/src/cdk/drag-drop/directives/drag.spec.ts @@ -2151,6 +2151,19 @@ describe('CdkDrag', () => { 'Expected cloned canvas to have the same content as the source.'); })); + it('should not throw when cloning an invalid canvas', fakeAsync(() => { + const fixture = createComponent(DraggableWithInvalidCanvasInDropZone); + fixture.detectChanges(); + const item = fixture.componentInstance.dragItems.toArray()[1].element.nativeElement; + + expect(() => { + startDraggingViaMouse(fixture, item); + tick(); + }).not.toThrow(); + + expect(document.querySelector('.cdk-drag-preview canvas')).toBeTruthy(); + })); + it('should clear the ids from descendants of the preview', fakeAsync(() => { const fixture = createComponent(DraggableInDropZone); fixture.detectChanges(); @@ -5949,6 +5962,30 @@ class DraggableWithCanvasInDropZone extends DraggableInDropZone implements After } } +@Component({ + template: ` +