1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-28 14:29:07 +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

@@ -277,7 +277,10 @@ const Collapse = (($) => {
// private
_getConfig(config) {
config = $.extend({}, Default, config)
config = {
...Default,
...config
}
config.toggle = Boolean(config.toggle) // coerce string values
Util.typeCheckConfig(NAME, config, DefaultType)
return config
@@ -338,12 +341,11 @@ const Collapse = (($) => {
return this.each(function () {
const $this = $(this)
let data = $this.data(DATA_KEY)
const _config = $.extend(
{},
Default,
$this.data(),
typeof config === 'object' && config
)
const _config = {
...Default,
...$this.data(),
...typeof config === 'object' && config
}
if (!data && _config.toggle && /show|hide/.test(config)) {
_config.toggle = false