1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-26 06:44:35 +02:00

Object spread : less jQuery more ES6 (#24665)

This commit is contained in:
Johann-S
2017-11-13 11:25:36 +01:00
committed by GitHub
parent 1354a929f9
commit 9a0bba9afa
9 changed files with 85 additions and 51 deletions

View File

@@ -227,7 +227,10 @@ const Modal = (($) => {
// private
_getConfig(config) {
config = $.extend({}, Default, config)
config = {
...Default,
...config
}
Util.typeCheckConfig(NAME, config, DefaultType)
return config
}
@@ -506,12 +509,11 @@ const Modal = (($) => {
static _jQueryInterface(config, relatedTarget) {
return this.each(function () {
let data = $(this).data(DATA_KEY)
const _config = $.extend(
{},
Modal.Default,
$(this).data(),
typeof config === 'object' && config
)
const _config = {
...Modal.Default,
...$(this).data(),
...typeof config === 'object' && config
}
if (!data) {
data = new Modal(this, _config)
@@ -547,7 +549,10 @@ const Modal = (($) => {
}
const config = $(target).data(DATA_KEY) ?
'toggle' : $.extend({}, $(target).data(), $(this).data())
'toggle' : {
...$(target).data(),
...$(this).data()
}
if (this.tagName === 'A' || this.tagName === 'AREA') {
event.preventDefault()