1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-26 21:39:08 +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

@@ -223,7 +223,10 @@ const Carousel = (($) => {
// private
_getConfig(config) {
config = $.extend({}, Default, config)
config = {
...Default,
...config
}
Util.typeCheckConfig(NAME, config, DefaultType)
return config
}
@@ -428,10 +431,16 @@ const Carousel = (($) => {
static _jQueryInterface(config) {
return this.each(function () {
let data = $(this).data(DATA_KEY)
const _config = $.extend({}, Default, $(this).data())
let _config = {
...Default,
...$(this).data()
}
if (typeof config === 'object') {
$.extend(_config, config)
_config = {
..._config,
...config
}
}
const action = typeof config === 'string' ? config : _config.slide
@@ -468,7 +477,10 @@ const Carousel = (($) => {
return
}
const config = $.extend({}, $(target).data(), $(this).data())
const config = {
...$(target).data(),
...$(this).data()
}
const slideIndex = this.getAttribute('data-slide-to')
if (slideIndex) {