5
5
6
6
import Vue from '../../../utils/vue'
7
7
import {
8
+ addClass ,
8
9
getAttr ,
10
+ getBCR ,
11
+ getCS ,
12
+ getStyle ,
9
13
hasAttr ,
10
14
removeAttr ,
11
- setAttr ,
12
- addClass ,
13
15
removeClass ,
14
- getBCR ,
15
- getCS ,
16
+ requestAF ,
16
17
selectAll ,
17
- requestAF
18
+ setAttr ,
19
+ setStyle
18
20
} from '../../../utils/dom'
19
21
import { isBrowser } from '../../../utils/env'
20
22
import { isNull } from '../../../utils/inspect'
@@ -101,8 +103,9 @@ const ModalManager = /*#__PURE__*/ Vue.extend({
101
103
if ( isNull ( this . baseZIndex ) && isBrowser ) {
102
104
// Create a temporary `div.modal-backdrop` to get computed z-index
103
105
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' )
106
109
document . body . appendChild ( div )
107
110
this . baseZIndex = toInteger ( getCS ( div ) . zIndex , DEFAULT_ZINDEX )
108
111
document . body . removeChild ( div )
@@ -113,7 +116,7 @@ const ModalManager = /*#__PURE__*/ Vue.extend({
113
116
if ( isNull ( this . scrollbarWidth ) && isBrowser ) {
114
117
// Create a temporary `div.measure-scrollbar` to get computed z-index
115
118
const div = document . createElement ( 'div' )
116
- div . className = 'modal-scrollbar-measure'
119
+ addClass ( div , 'modal-scrollbar-measure' )
117
120
document . body . appendChild ( div )
118
121
this . scrollbarWidth = getBCR ( div ) . width - div . clientWidth
119
122
document . body . removeChild ( div )
@@ -156,31 +159,31 @@ const ModalManager = /*#__PURE__*/ Vue.extend({
156
159
// Adjust fixed content padding
157
160
/* istanbul ignore next: difficult to test in JSDOM */
158
161
selectAll ( Selector . FIXED_CONTENT ) . forEach ( el => {
159
- const actualPadding = el . style . paddingRight
162
+ const actualPadding = getStyle ( el , ' paddingRight' )
160
163
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` )
162
165
body . _paddingChangedForModal . push ( el )
163
166
} )
164
167
// Adjust sticky content margin
165
168
/* istanbul ignore next: difficult to test in JSDOM */
166
169
selectAll ( Selector . STICKY_CONTENT ) . forEach ( el => /* istanbul ignore next */ {
167
- const actualMargin = el . style . marginRight
170
+ const actualMargin = getStyle ( el , ' marginRight' )
168
171
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` )
170
173
body . _marginChangedForModal . push ( el )
171
174
} )
172
175
// Adjust <b-navbar-toggler> margin
173
176
/* istanbul ignore next: difficult to test in JSDOM */
174
177
selectAll ( Selector . NAVBAR_TOGGLER ) . forEach ( el => /* istanbul ignore next */ {
175
- const actualMargin = el . style . marginRight
178
+ const actualMargin = getStyle ( el , ' marginRight' )
176
179
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` )
178
181
body . _marginChangedForModal . push ( el )
179
182
} )
180
183
// Adjust body padding
181
- const actualPadding = body . style . paddingRight
184
+ const actualPadding = getStyle ( body , ' paddingRight' )
182
185
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` )
184
187
}
185
188
} ,
186
189
resetScrollbar ( ) {
@@ -190,7 +193,7 @@ const ModalManager = /*#__PURE__*/ Vue.extend({
190
193
body . _paddingChangedForModal . forEach ( el => {
191
194
/* istanbul ignore next: difficult to test in JSDOM */
192
195
if ( hasAttr ( el , 'data-padding-right' ) ) {
193
- el . style . paddingRight = getAttr ( el , 'data-padding-right' ) || ''
196
+ setStyle ( el , ' paddingRight' , getAttr ( el , 'data-padding-right' ) || '' )
194
197
removeAttr ( el , 'data-padding-right' )
195
198
}
196
199
} )
@@ -200,7 +203,7 @@ const ModalManager = /*#__PURE__*/ Vue.extend({
200
203
body . _marginChangedForModal . forEach ( el => {
201
204
/* istanbul ignore next: difficult to test in JSDOM */
202
205
if ( hasAttr ( el , 'data-margin-right' ) ) {
203
- el . style . marginRight = getAttr ( el , 'data-margin-right' ) || ''
206
+ setStyle ( el , ' marginRight' , getAttr ( el , 'data-margin-right' ) || '' )
204
207
removeAttr ( el , 'data-margin-right' )
205
208
}
206
209
} )
@@ -209,7 +212,7 @@ const ModalManager = /*#__PURE__*/ Vue.extend({
209
212
body . _marginChangedForModal = null
210
213
// Restore body padding
211
214
if ( hasAttr ( body , 'data-padding-right' ) ) {
212
- body . style . paddingRight = getAttr ( body , 'data-padding-right' ) || ''
215
+ setStyle ( body , ' paddingRight' , getAttr ( body , 'data-padding-right' ) || '' )
213
216
removeAttr ( body , 'data-padding-right' )
214
217
}
215
218
}
0 commit comments