@@ -23,7 +23,6 @@ import {
23
23
ViewEncapsulation ,
24
24
} from '@angular/core' ;
25
25
import { TestBed , ComponentFixture , fakeAsync , flush , tick } from '@angular/core/testing' ;
26
- import { DOCUMENT } from '@angular/common' ;
27
26
import { ViewportRuler , CdkScrollableModule } from '@angular/cdk/scrolling' ;
28
27
import { _supportsShadowDom } from '@angular/cdk/platform' ;
29
28
import { of as observableOf } from 'rxjs' ;
@@ -2490,7 +2489,6 @@ describe('CdkDrag', () => {
2490
2489
startDraggingViaMouse ( fixture , item ) ;
2491
2490
2492
2491
const preview = document . querySelector ( '.cdk-drag-preview' ) as HTMLElement ;
2493
- const previewContainer = document . querySelector ( '.cdk-drag-preview-container' ) as HTMLElement ;
2494
2492
const previewRect = preview . getBoundingClientRect ( ) ;
2495
2493
const zeroPxRegex = / ^ 0 ( p x ) ? $ / ;
2496
2494
@@ -2512,23 +2510,18 @@ describe('CdkDrag', () => {
2512
2510
. withContext ( 'Expected element to be removed from layout' )
2513
2511
. toBe ( '-999em' ) ;
2514
2512
expect ( item . style . opacity ) . withContext ( 'Expected element to be invisible' ) . toBe ( '0' ) ;
2515
- expect ( previewContainer )
2516
- . withContext ( 'Expected preview container to be in the DOM' )
2517
- . toBeTruthy ( ) ;
2518
- expect ( previewContainer . style . color )
2519
- . withContext ( 'Expected preview container to reset user agent color' )
2520
- . toBe ( 'inherit' ) ;
2521
- expect ( previewContainer . style . margin )
2522
- . withContext ( 'Expected preview container to reset user agent margin' )
2523
- . toMatch ( zeroPxRegex ) ;
2524
- expect ( previewContainer . style . padding )
2525
- . withContext ( 'Expected preview container to reset user agent padding' )
2513
+ expect ( preview ) . withContext ( 'Expected preview to be in the DOM' ) . toBeTruthy ( ) ;
2514
+ expect ( preview . getAttribute ( 'popover' ) )
2515
+ . withContext ( 'Expected preview to be a popover' )
2516
+ . toBe ( 'manual' ) ;
2517
+ expect ( preview . style . margin )
2518
+ . withContext ( 'Expected preview to reset the margin' )
2526
2519
. toMatch ( zeroPxRegex ) ;
2527
2520
expect ( preview . textContent ! . trim ( ) )
2528
2521
. withContext ( 'Expected preview content to match element' )
2529
2522
. toContain ( 'One' ) ;
2530
- expect ( previewContainer . getAttribute ( 'dir' ) )
2531
- . withContext ( 'Expected preview container element to inherit the directionality.' )
2523
+ expect ( preview . getAttribute ( 'dir' ) )
2524
+ . withContext ( 'Expected preview element to inherit the directionality.' )
2532
2525
. toBe ( 'ltr' ) ;
2533
2526
expect ( previewRect . width )
2534
2527
. withContext ( 'Expected preview width to match element' )
@@ -2539,8 +2532,8 @@ describe('CdkDrag', () => {
2539
2532
expect ( preview . style . pointerEvents )
2540
2533
. withContext ( 'Expected pointer events to be disabled on the preview' )
2541
2534
. toBe ( 'none' ) ;
2542
- expect ( previewContainer . style . zIndex )
2543
- . withContext ( 'Expected preview container to have a high default zIndex.' )
2535
+ expect ( preview . style . zIndex )
2536
+ . withContext ( 'Expected preview to have a high default zIndex.' )
2544
2537
. toBe ( '1000' ) ;
2545
2538
// Use a regex here since some browsers normalize 0 to 0px, but others don't.
2546
2539
// Use a regex here since some browsers normalize 0 to 0px, but others don't.
@@ -2561,8 +2554,8 @@ describe('CdkDrag', () => {
2561
2554
expect ( item . style . top ) . withContext ( 'Expected element to be within the layout' ) . toBeFalsy ( ) ;
2562
2555
expect ( item . style . left ) . withContext ( 'Expected element to be within the layout' ) . toBeFalsy ( ) ;
2563
2556
expect ( item . style . opacity ) . withContext ( 'Expected element to be visible' ) . toBeFalsy ( ) ;
2564
- expect ( previewContainer . parentNode )
2565
- . withContext ( 'Expected preview container to be removed from the DOM' )
2557
+ expect ( preview . parentNode )
2558
+ . withContext ( 'Expected preview to be removed from the DOM' )
2566
2559
. toBeFalsy ( ) ;
2567
2560
} ) ) ;
2568
2561
@@ -2580,59 +2573,10 @@ describe('CdkDrag', () => {
2580
2573
const item = fixture . componentInstance . dragItems . toArray ( ) [ 1 ] . element . nativeElement ;
2581
2574
startDraggingViaMouse ( fixture , item ) ;
2582
2575
2583
- const preview = document . querySelector ( '.cdk-drag-preview-container ' ) ! as HTMLElement ;
2576
+ const preview = document . querySelector ( '.cdk-drag-preview' ) ! as HTMLElement ;
2584
2577
expect ( preview . style . zIndex ) . toBe ( '3000' ) ;
2585
2578
} ) ) ;
2586
2579
2587
- it ( 'should create the preview inside the fullscreen element when in fullscreen mode' , fakeAsync ( ( ) => {
2588
- // Provide a limited stub of the document since we can't trigger fullscreen
2589
- // mode in unit tests and there are some issues with doing it in e2e tests.
2590
- const fakeDocument = {
2591
- body : document . body ,
2592
- documentElement : document . documentElement ,
2593
- fullscreenElement : document . createElement ( 'div' ) ,
2594
- ELEMENT_NODE : Node . ELEMENT_NODE ,
2595
- querySelectorAll : ( ...args : [ string ] ) => document . querySelectorAll ( ...args ) ,
2596
- querySelector : ( ...args : [ string ] ) => document . querySelector ( ...args ) ,
2597
- createElement : ( ...args : [ string ] ) => document . createElement ( ...args ) ,
2598
- createTextNode : ( ...args : [ string ] ) => document . createTextNode ( ...args ) ,
2599
- addEventListener : (
2600
- ...args : [
2601
- string ,
2602
- EventListenerOrEventListenerObject ,
2603
- ( boolean | AddEventListenerOptions | undefined ) ?,
2604
- ]
2605
- ) => document . addEventListener ( ...args ) ,
2606
- removeEventListener : (
2607
- ...args : [
2608
- string ,
2609
- EventListenerOrEventListenerObject ,
2610
- ( boolean | AddEventListenerOptions | undefined ) ?,
2611
- ]
2612
- ) => document . addEventListener ( ...args ) ,
2613
- createComment : ( text : string ) => document . createComment ( text ) ,
2614
- } ;
2615
- const fixture = createComponent ( DraggableInDropZone , [
2616
- {
2617
- provide : DOCUMENT ,
2618
- useFactory : ( ) => fakeDocument ,
2619
- } ,
2620
- ] ) ;
2621
- fixture . detectChanges ( ) ;
2622
- const item = fixture . componentInstance . dragItems . toArray ( ) [ 1 ] . element . nativeElement ;
2623
-
2624
- document . body . appendChild ( fakeDocument . fullscreenElement ) ;
2625
- startDraggingViaMouse ( fixture , item ) ;
2626
- flush ( ) ;
2627
-
2628
- const previewContainer = document . querySelector (
2629
- '.cdk-drag-preview-container' ,
2630
- ) ! as HTMLElement ;
2631
-
2632
- expect ( previewContainer . parentNode ) . toBe ( fakeDocument . fullscreenElement ) ;
2633
- fakeDocument . fullscreenElement . remove ( ) ;
2634
- } ) ) ;
2635
-
2636
2580
it ( 'should be able to constrain the preview position' , fakeAsync ( ( ) => {
2637
2581
const fixture = createComponent ( DraggableInDropZone ) ;
2638
2582
fixture . componentInstance . boundarySelector = '.cdk-drop-list' ;
@@ -2928,8 +2872,8 @@ describe('CdkDrag', () => {
2928
2872
const item = fixture . componentInstance . dragItems . toArray ( ) [ 1 ] . element . nativeElement ;
2929
2873
startDraggingViaMouse ( fixture , item ) ;
2930
2874
2931
- expect ( document . querySelector ( '.cdk-drag-preview-container ' ) ! . getAttribute ( 'dir' ) )
2932
- . withContext ( 'Expected preview container to inherit the directionality.' )
2875
+ expect ( document . querySelector ( '.cdk-drag-preview' ) ! . getAttribute ( 'dir' ) )
2876
+ . withContext ( 'Expected preview to inherit the directionality.' )
2933
2877
. toBe ( 'rtl' ) ;
2934
2878
} ) ) ;
2935
2879
@@ -2941,7 +2885,6 @@ describe('CdkDrag', () => {
2941
2885
startDraggingViaMouse ( fixture , item ) ;
2942
2886
2943
2887
const preview = document . querySelector ( '.cdk-drag-preview' ) as HTMLElement ;
2944
- const previewContainer = document . querySelector ( '.cdk-drag-preview-container' ) as HTMLElement ;
2945
2888
2946
2889
// Add a duration since the tests won't include one.
2947
2890
preview . style . transitionDuration = '500ms' ;
@@ -2954,13 +2897,13 @@ describe('CdkDrag', () => {
2954
2897
fixture . detectChanges ( ) ;
2955
2898
tick ( 250 ) ;
2956
2899
2957
- expect ( previewContainer . parentNode )
2900
+ expect ( preview . parentNode )
2958
2901
. withContext ( 'Expected preview to be in the DOM mid-way through the transition' )
2959
2902
. toBeTruthy ( ) ;
2960
2903
2961
2904
tick ( 500 ) ;
2962
2905
2963
- expect ( previewContainer . parentNode )
2906
+ expect ( preview . parentNode )
2964
2907
. withContext ( 'Expected preview to be removed from the DOM if the transition timed out' )
2965
2908
. toBeFalsy ( ) ;
2966
2909
} ) ) ;
@@ -3064,7 +3007,6 @@ describe('CdkDrag', () => {
3064
3007
startDraggingViaMouse ( fixture , item ) ;
3065
3008
3066
3009
const preview = document . querySelector ( '.cdk-drag-preview' ) ! as HTMLElement ;
3067
- const previewContainer = document . querySelector ( '.cdk-drag-preview-container' ) as HTMLElement ;
3068
3010
preview . style . transition = 'opacity 500ms ease' ;
3069
3011
3070
3012
dispatchMouseEvent ( document , 'mousemove' , 50 , 50 ) ;
@@ -3074,8 +3016,8 @@ describe('CdkDrag', () => {
3074
3016
fixture . detectChanges ( ) ;
3075
3017
tick ( 0 ) ;
3076
3018
3077
- expect ( previewContainer . parentNode )
3078
- . withContext ( 'Expected preview container to be removed from the DOM immediately' )
3019
+ expect ( preview . parentNode )
3020
+ . withContext ( 'Expected preview to be removed from the DOM immediately' )
3079
3021
. toBeFalsy ( ) ;
3080
3022
} ) ) ;
3081
3023
@@ -3087,7 +3029,6 @@ describe('CdkDrag', () => {
3087
3029
startDraggingViaMouse ( fixture , item ) ;
3088
3030
3089
3031
const preview = document . querySelector ( '.cdk-drag-preview' ) ! as HTMLElement ;
3090
- const previewContainer = document . querySelector ( '.cdk-drag-preview-container' ) as HTMLElement ;
3091
3032
preview . style . transition = 'opacity 500ms ease, transform 1000ms ease' ;
3092
3033
3093
3034
dispatchMouseEvent ( document , 'mousemove' , 50 , 50 ) ;
@@ -3097,17 +3038,15 @@ describe('CdkDrag', () => {
3097
3038
fixture . detectChanges ( ) ;
3098
3039
tick ( 500 ) ;
3099
3040
3100
- expect ( previewContainer . parentNode )
3101
- . withContext (
3102
- 'Expected preview container to be in the DOM at the end of the opacity transition' ,
3103
- )
3041
+ expect ( preview . parentNode )
3042
+ . withContext ( 'Expected preview to be in the DOM at the end of the opacity transition' )
3104
3043
. toBeTruthy ( ) ;
3105
3044
3106
3045
tick ( 1000 ) ;
3107
3046
3108
- expect ( previewContainer . parentNode )
3047
+ expect ( preview . parentNode )
3109
3048
. withContext (
3110
- 'Expected preview container to be removed from the DOM at the end of the transform transition' ,
3049
+ 'Expected preview to be removed from the DOM at the end of the transform transition' ,
3111
3050
)
3112
3051
. toBeFalsy ( ) ;
3113
3052
} ) ) ;
@@ -3149,8 +3088,8 @@ describe('CdkDrag', () => {
3149
3088
const item = fixture . componentInstance . dragItems . toArray ( ) [ 1 ] . element . nativeElement ;
3150
3089
3151
3090
startDraggingViaMouse ( fixture , item ) ;
3152
- const previewContainer = document . querySelector ( '.cdk-drag-preview-container ' ) as HTMLElement ;
3153
- expect ( previewContainer . parentNode ) . toBe ( document . body ) ;
3091
+ const preview = document . querySelector ( '.cdk-drag-preview' ) as HTMLElement ;
3092
+ expect ( preview . parentNode ) . toBe ( document . body ) ;
3154
3093
} ) ) ;
3155
3094
3156
3095
it ( 'should insert the preview into the parent node if previewContainer is set to `parent`' , fakeAsync ( ( ) => {
@@ -3161,9 +3100,9 @@ describe('CdkDrag', () => {
3161
3100
const list = fixture . nativeElement . querySelector ( '.drop-list' ) ;
3162
3101
3163
3102
startDraggingViaMouse ( fixture , item ) ;
3164
- const previewContainer = document . querySelector ( '.cdk-drag-preview-container ' ) as HTMLElement ;
3103
+ const preview = document . querySelector ( '.cdk-drag-preview' ) as HTMLElement ;
3165
3104
expect ( list ) . toBeTruthy ( ) ;
3166
- expect ( previewContainer . parentNode ) . toBe ( list ) ;
3105
+ expect ( preview . parentNode ) . toBe ( list ) ;
3167
3106
} ) ) ;
3168
3107
3169
3108
it ( 'should insert the preview into a particular element, if specified' , fakeAsync ( ( ) => {
@@ -3176,25 +3115,9 @@ describe('CdkDrag', () => {
3176
3115
fixture . componentInstance . previewContainer = previewContainer ;
3177
3116
fixture . detectChanges ( ) ;
3178
3117
3179
- startDraggingViaMouse ( fixture , item ) ;
3180
- const previewContainerElement = document . querySelector (
3181
- '.cdk-drag-preview-container' ,
3182
- ) as HTMLElement ;
3183
- expect ( previewContainerElement . parentNode ) . toBe ( previewContainer . nativeElement ) ;
3184
- } ) ) ;
3185
-
3186
- it ( 'should not create a popover wrapper if disablePreviewPopover is enabled' , fakeAsync ( ( ) => {
3187
- const fixture = createComponent ( DraggableInDropZone ) ;
3188
- fixture . componentInstance . previewContainer = 'global' ;
3189
- fixture . componentInstance . disablePreviewPopover = true ;
3190
- fixture . detectChanges ( ) ;
3191
- const item = fixture . componentInstance . dragItems . toArray ( ) [ 1 ] . element . nativeElement ;
3192
-
3193
3118
startDraggingViaMouse ( fixture , item ) ;
3194
3119
const preview = document . querySelector ( '.cdk-drag-preview' ) as HTMLElement ;
3195
- expect ( document . querySelector ( '.cdk-drag-preview-container' ) ) . toBeFalsy ( ) ;
3196
- expect ( preview ) . toBeTruthy ( ) ;
3197
- expect ( preview . parentElement ) . toBe ( document . body ) ;
3120
+ expect ( preview . parentNode ) . toBe ( previewContainer . nativeElement ) ;
3198
3121
} ) ) ;
3199
3122
3200
3123
it ( 'should remove the id from the placeholder' , fakeAsync ( ( ) => {
@@ -3706,17 +3629,15 @@ describe('CdkDrag', () => {
3706
3629
3707
3630
startDraggingViaMouse ( fixture , item ) ;
3708
3631
3709
- const previewContainer = document . querySelector ( '.cdk-drag-preview-container ' ) as HTMLElement ;
3632
+ const preview = document . querySelector ( '.cdk-drag-preview' ) as HTMLElement ;
3710
3633
3711
- expect ( previewContainer . parentNode )
3712
- . withContext ( 'Expected preview container to be in the DOM' )
3713
- . toBeTruthy ( ) ;
3634
+ expect ( preview . parentNode ) . withContext ( 'Expected preview to be in the DOM' ) . toBeTruthy ( ) ;
3714
3635
expect ( item . parentNode ) . withContext ( 'Expected drag item to be in the DOM' ) . toBeTruthy ( ) ;
3715
3636
3716
3637
fixture . destroy ( ) ;
3717
3638
3718
- expect ( previewContainer . parentNode )
3719
- . withContext ( 'Expected preview container to be removed from the DOM' )
3639
+ expect ( preview . parentNode )
3640
+ . withContext ( 'Expected preview to be removed from the DOM' )
3720
3641
. toBeFalsy ( ) ;
3721
3642
expect ( item . parentNode )
3722
3643
. withContext ( 'Expected drag item to be removed from the DOM' )
@@ -6950,7 +6871,6 @@ const DROP_ZONE_FIXTURE_TEMPLATE = `
6950
6871
[cdkDragBoundary]="boundarySelector"
6951
6872
[cdkDragPreviewClass]="previewClass"
6952
6873
[cdkDragPreviewContainer]="previewContainer"
6953
- [cdkDragDisablePreviewPopover]="disablePreviewPopover"
6954
6874
[style.height.px]="item.height"
6955
6875
[style.margin-bottom.px]="item.margin"
6956
6876
(cdkDragStarted)="startedSpy($event)"
@@ -6980,7 +6900,6 @@ class DraggableInDropZone implements AfterViewInit {
6980
6900
} ) ;
6981
6901
startedSpy = jasmine . createSpy ( 'started spy' ) ;
6982
6902
previewContainer : PreviewContainer = 'global' ;
6983
- disablePreviewPopover = false ;
6984
6903
6985
6904
constructor ( protected _elementRef : ElementRef ) { }
6986
6905
0 commit comments