mirror of
https://github.com/twbs/bootstrap.git
synced 2024-12-01 13:24:25 +01:00
Backport (#30383)
fix: ensure totype always return stringified null when null passed
This commit is contained in:
parent
0c8d8a48e1
commit
dabd458b4b
@ -19,6 +19,10 @@ const MILLISECONDS_MULTIPLIER = 1000
|
||||
|
||||
// Shoutout AngusCroll (https://goo.gl/pxwQGp)
|
||||
function toType(obj) {
|
||||
if (obj === null || typeof obj === 'undefined') {
|
||||
return `${obj}`
|
||||
}
|
||||
|
||||
return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase()
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,26 @@ $(function () {
|
||||
}
|
||||
})
|
||||
|
||||
QUnit.test('Util.typeCheckConfig should return null/undefined stringified when passed', function (assert) {
|
||||
assert.expect(1)
|
||||
var namePlugin = 'collapse'
|
||||
var defaultType = {
|
||||
toggle: '(null|undefined)'
|
||||
}
|
||||
var config = {
|
||||
toggle: null
|
||||
}
|
||||
|
||||
Util.typeCheckConfig(namePlugin, config, defaultType)
|
||||
|
||||
// eslint-disable-next-line
|
||||
config.toggle = undefined
|
||||
|
||||
Util.typeCheckConfig(namePlugin, config, defaultType)
|
||||
|
||||
assert.strictEqual(true, true)
|
||||
})
|
||||
|
||||
QUnit.test('Util.isElement should check if we passed an element or not', function (assert) {
|
||||
assert.expect(3)
|
||||
var $div = $('<div id="test"></div>').appendTo($('#qunit-fixture'))
|
||||
|
Loading…
Reference in New Issue
Block a user