mirror of
https://github.com/twbs/bootstrap.git
synced 2025-02-19 16:54:24 +01:00
Making .tooltip('show') throw an error on elements with display:none (#20940)
This commit is contained in:
parent
0974267b8c
commit
a7f1b59959
@ -239,6 +239,9 @@ const Tooltip = (($) => {
|
||||
}
|
||||
|
||||
show() {
|
||||
if ($(this.element).css('display') === 'none') {
|
||||
throw new Error('Please use show on visible elements')
|
||||
}
|
||||
let showEvent = $.Event(this.constructor.Event.SHOW)
|
||||
|
||||
if (this.isWithContent() && this._isEnabled) {
|
||||
|
@ -320,4 +320,16 @@ $(function () {
|
||||
.bootstrapPopover('show')
|
||||
})
|
||||
|
||||
QUnit.test('should throw an error when show is called on hidden elements', function (assert) {
|
||||
assert.expect(1)
|
||||
var done = assert.async()
|
||||
|
||||
try {
|
||||
$('<div data-toggle="popover" data-title="some title" data-content="@Johann-S" style="display: none"/>').bootstrapPopover('show')
|
||||
}
|
||||
catch (err) {
|
||||
assert.strictEqual(err.message, 'Please use show on visible elements')
|
||||
done()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -185,6 +185,19 @@ $(function () {
|
||||
.bootstrapTooltip('show')
|
||||
})
|
||||
|
||||
QUnit.test('should throw an error when show is called on hidden elements', function (assert) {
|
||||
assert.expect(1)
|
||||
var done = assert.async()
|
||||
|
||||
try {
|
||||
$('<div title="tooltip title" style="display: none"/>').bootstrapTooltip('show')
|
||||
}
|
||||
catch (err) {
|
||||
assert.strictEqual(err.message, 'Please use show on visible elements')
|
||||
done()
|
||||
}
|
||||
})
|
||||
|
||||
QUnit.test('should fire inserted event', function (assert) {
|
||||
assert.expect(2)
|
||||
var done = assert.async()
|
||||
|
Loading…
x
Reference in New Issue
Block a user