@@ -106,6 +106,18 @@ describe('position mixin', () => {
106106 expect ( overlay . opened ) . to . be . false ;
107107 } ) ;
108108
109+ it ( 'should reset styles when positionTarget is reset' , async ( ) => {
110+ overlay . positionTarget = null ;
111+ await nextRender ( ) ;
112+
113+ expect ( overlay . style . top ) . to . equal ( '' ) ;
114+ expect ( overlay . style . bottom ) . to . equal ( '' ) ;
115+ expect ( overlay . style . left ) . to . equal ( '' ) ;
116+ expect ( overlay . style . right ) . to . equal ( '' ) ;
117+ expect ( overlay . style . alignItems ) . to . equal ( '' ) ;
118+ expect ( overlay . style . justifyContent ) . to . equal ( '' ) ;
119+ } ) ;
120+
109121 describe ( 'vertical align top' , ( ) => {
110122 beforeEach ( ( ) => {
111123 overlay . verticalAlign = TOP ;
@@ -125,6 +137,13 @@ describe('position mixin', () => {
125137 expect ( parent . hasAttribute ( 'bottom-aligned' ) ) . to . be . false ;
126138 } ) ;
127139
140+ it ( 'should remove top-aligned attribute when positionTarget is reset' , async ( ) => {
141+ overlay . positionTarget = null ;
142+ await nextRender ( ) ;
143+ expect ( overlay . hasAttribute ( 'top-aligned' ) ) . to . be . false ;
144+ expect ( parent . hasAttribute ( 'top-aligned' ) ) . to . be . false ;
145+ } ) ;
146+
128147 it ( 'should align top edges when overlay part is animated' , async ( ) => {
129148 overlay . classList . add ( 'animated' ) ;
130149 await oneEvent ( overlay . $ . overlay , 'animationend' ) ;
@@ -146,6 +165,16 @@ describe('position mixin', () => {
146165 expect ( parent . hasAttribute ( 'bottom-aligned' ) ) . to . be . true ;
147166 } ) ;
148167
168+ it ( 'should bottom top-aligned attribute when positionTarget is reset' , async ( ) => {
169+ target . style . top = `${ targetPositionToFlipOverlay + 3 } px` ;
170+ updatePosition ( ) ;
171+
172+ overlay . positionTarget = null ;
173+ await nextRender ( ) ;
174+ expect ( overlay . hasAttribute ( 'bottom-aligned' ) ) . to . be . false ;
175+ expect ( parent . hasAttribute ( 'bottom-aligned' ) ) . to . be . false ;
176+ } ) ;
177+
149178 it ( 'should flip when out of space and squeezed smaller than current available space' , ( ) => {
150179 target . style . top = `${ targetPositionToFlipOverlay + 3 } px` ;
151180
@@ -384,6 +413,13 @@ describe('position mixin', () => {
384413 expect ( parent . hasAttribute ( 'end-aligned' ) ) . to . be . false ;
385414 } ) ;
386415
416+ it ( 'should remove start-aligned attribute when positionTarget is reset' , async ( ) => {
417+ overlay . positionTarget = null ;
418+ await nextRender ( ) ;
419+ expect ( overlay . hasAttribute ( 'start-aligned' ) ) . to . be . false ;
420+ expect ( parent . hasAttribute ( 'start-aligned' ) ) . to . be . false ;
421+ } ) ;
422+
387423 it ( 'should align right edges with right-to-left' , async ( ) => {
388424 document . dir = 'rtl' ;
389425 await nextRender ( ) ;
@@ -407,6 +443,16 @@ describe('position mixin', () => {
407443 expect ( parent . hasAttribute ( 'end-aligned' ) ) . to . be . true ;
408444 } ) ;
409445
446+ it ( 'should remove end-aligned attribute when positionTarget is reset' , async ( ) => {
447+ target . style . left = `${ targetPositionToFlipOverlay + 3 } px` ;
448+ updatePosition ( ) ;
449+
450+ overlay . positionTarget = null ;
451+ await nextRender ( ) ;
452+ expect ( overlay . hasAttribute ( 'end-aligned' ) ) . to . be . false ;
453+ expect ( parent . hasAttribute ( 'end-aligned' ) ) . to . be . false ;
454+ } ) ;
455+
410456 it ( 'should flip when out of space and squeezed smaller than current available space' , ( ) => {
411457 target . style . left = `${ targetPositionToFlipOverlay + 3 } px` ;
412458
0 commit comments