55
66import Vue from '../../../utils/vue'
77import {
8+ addClass ,
89 getAttr ,
10+ getBCR ,
11+ getCS ,
12+ getStyle ,
913 hasAttr ,
1014 removeAttr ,
11- setAttr ,
12- addClass ,
1315 removeClass ,
14- getBCR ,
15- getCS ,
16+ requestAF ,
1617 selectAll ,
17- requestAF
18+ setAttr ,
19+ setStyle
1820} from '../../../utils/dom'
1921import { isBrowser } from '../../../utils/env'
2022import { isNull } from '../../../utils/inspect'
@@ -101,8 +103,9 @@ const ModalManager = /*#__PURE__*/ Vue.extend({
101103 if ( isNull ( this . baseZIndex ) && isBrowser ) {
102104 // Create a temporary `div.modal-backdrop` to get computed z-index
103105 const div = document . createElement ( 'div' )
104- div . className = 'modal-backdrop d-none'
105- div . style . display = 'none'
106+ addClass ( div , 'modal-backdrop' )
107+ addClass ( div , 'd-none' )
108+ setStyle ( div , 'display' , 'none' )
106109 document . body . appendChild ( div )
107110 this . baseZIndex = toInteger ( getCS ( div ) . zIndex , DEFAULT_ZINDEX )
108111 document . body . removeChild ( div )
@@ -113,7 +116,7 @@ const ModalManager = /*#__PURE__*/ Vue.extend({
113116 if ( isNull ( this . scrollbarWidth ) && isBrowser ) {
114117 // Create a temporary `div.measure-scrollbar` to get computed z-index
115118 const div = document . createElement ( 'div' )
116- div . className = 'modal-scrollbar-measure'
119+ addClass ( div , 'modal-scrollbar-measure' )
117120 document . body . appendChild ( div )
118121 this . scrollbarWidth = getBCR ( div ) . width - div . clientWidth
119122 document . body . removeChild ( div )
@@ -156,31 +159,31 @@ const ModalManager = /*#__PURE__*/ Vue.extend({
156159 // Adjust fixed content padding
157160 /* istanbul ignore next: difficult to test in JSDOM */
158161 selectAll ( Selector . FIXED_CONTENT ) . forEach ( el => {
159- const actualPadding = el . style . paddingRight
162+ const actualPadding = getStyle ( el , ' paddingRight' )
160163 setAttr ( el , 'data-padding-right' , actualPadding )
161- el . style . paddingRight = `${ toFloat ( getCS ( el ) . paddingRight , 0 ) + scrollbarWidth } px`
164+ setStyle ( el , ' paddingRight' , `${ toFloat ( getCS ( el ) . paddingRight , 0 ) + scrollbarWidth } px` )
162165 body . _paddingChangedForModal . push ( el )
163166 } )
164167 // Adjust sticky content margin
165168 /* istanbul ignore next: difficult to test in JSDOM */
166169 selectAll ( Selector . STICKY_CONTENT ) . forEach ( el => /* istanbul ignore next */ {
167- const actualMargin = el . style . marginRight
170+ const actualMargin = getStyle ( el , ' marginRight' )
168171 setAttr ( el , 'data-margin-right' , actualMargin )
169- el . style . marginRight = `${ toFloat ( getCS ( el ) . marginRight , 0 ) - scrollbarWidth } px`
172+ setStyle ( el , ' marginRight' , `${ toFloat ( getCS ( el ) . marginRight , 0 ) - scrollbarWidth } px` )
170173 body . _marginChangedForModal . push ( el )
171174 } )
172175 // Adjust <b-navbar-toggler> margin
173176 /* istanbul ignore next: difficult to test in JSDOM */
174177 selectAll ( Selector . NAVBAR_TOGGLER ) . forEach ( el => /* istanbul ignore next */ {
175- const actualMargin = el . style . marginRight
178+ const actualMargin = getStyle ( el , ' marginRight' )
176179 setAttr ( el , 'data-margin-right' , actualMargin )
177- el . style . marginRight = `${ toFloat ( getCS ( el ) . marginRight , 0 ) + scrollbarWidth } px`
180+ setStyle ( el , ' marginRight' , `${ toFloat ( getCS ( el ) . marginRight , 0 ) + scrollbarWidth } px` )
178181 body . _marginChangedForModal . push ( el )
179182 } )
180183 // Adjust body padding
181- const actualPadding = body . style . paddingRight
184+ const actualPadding = getStyle ( body , ' paddingRight' )
182185 setAttr ( body , 'data-padding-right' , actualPadding )
183- body . style . paddingRight = `${ toFloat ( getCS ( body ) . paddingRight , 0 ) + scrollbarWidth } px`
186+ setStyle ( body , ' paddingRight' , `${ toFloat ( getCS ( body ) . paddingRight , 0 ) + scrollbarWidth } px` )
184187 }
185188 } ,
186189 resetScrollbar ( ) {
@@ -190,7 +193,7 @@ const ModalManager = /*#__PURE__*/ Vue.extend({
190193 body . _paddingChangedForModal . forEach ( el => {
191194 /* istanbul ignore next: difficult to test in JSDOM */
192195 if ( hasAttr ( el , 'data-padding-right' ) ) {
193- el . style . paddingRight = getAttr ( el , 'data-padding-right' ) || ''
196+ setStyle ( el , ' paddingRight' , getAttr ( el , 'data-padding-right' ) || '' )
194197 removeAttr ( el , 'data-padding-right' )
195198 }
196199 } )
@@ -200,7 +203,7 @@ const ModalManager = /*#__PURE__*/ Vue.extend({
200203 body . _marginChangedForModal . forEach ( el => {
201204 /* istanbul ignore next: difficult to test in JSDOM */
202205 if ( hasAttr ( el , 'data-margin-right' ) ) {
203- el . style . marginRight = getAttr ( el , 'data-margin-right' ) || ''
206+ setStyle ( el , ' marginRight' , getAttr ( el , 'data-margin-right' ) || '' )
204207 removeAttr ( el , 'data-margin-right' )
205208 }
206209 } )
@@ -209,7 +212,7 @@ const ModalManager = /*#__PURE__*/ Vue.extend({
209212 body . _marginChangedForModal = null
210213 // Restore body padding
211214 if ( hasAttr ( body , 'data-padding-right' ) ) {
212- body . style . paddingRight = getAttr ( body , 'data-padding-right' ) || ''
215+ setStyle ( body , ' paddingRight' , getAttr ( body , 'data-padding-right' ) || '' )
213216 removeAttr ( body , 'data-padding-right' )
214217 }
215218 }
0 commit comments