mirror of
https://github.com/twbs/bootstrap.git
synced 2024-11-29 11:24:18 +01:00
Popover + Tooltip - fix error when content or title is a number
This commit is contained in:
parent
cb4bc89fdf
commit
5142de7e59
@ -605,6 +605,14 @@ const Tooltip = (($) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (config.title && typeof config.title === 'number') {
|
||||
config.title = config.title.toString()
|
||||
}
|
||||
|
||||
if (config.content && typeof config.content === 'number') {
|
||||
config.content = config.content.toString()
|
||||
}
|
||||
|
||||
Util.typeCheckConfig(
|
||||
NAME,
|
||||
config,
|
||||
|
@ -364,4 +364,22 @@ $(function () {
|
||||
})
|
||||
.modal('show')
|
||||
})
|
||||
|
||||
QUnit.test('should convert number to string without error for content and title', function (assert) {
|
||||
assert.expect(2)
|
||||
var done = assert.async()
|
||||
var $popover = $('<a href="#">@mdo</a>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapPopover({
|
||||
title: 5,
|
||||
content: 7
|
||||
})
|
||||
.on('shown.bs.popover', function () {
|
||||
assert.strictEqual($('.popover .popover-title').text(), '5')
|
||||
assert.strictEqual($('.popover .popover-content').text(), '7')
|
||||
done()
|
||||
})
|
||||
|
||||
$popover.bootstrapPopover('show')
|
||||
})
|
||||
})
|
||||
|
@ -886,4 +886,20 @@ $(function () {
|
||||
|
||||
$el.bootstrapTooltip('hide')
|
||||
})
|
||||
|
||||
QUnit.test('should convert number in title to string', function (assert) {
|
||||
assert.expect(1)
|
||||
var done = assert.async()
|
||||
var $el = $('<a href="#" rel="tooltip" title="7"/>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapTooltip('show')
|
||||
.on('shown.bs.tooltip', function () {
|
||||
var tooltip = $el.data('bs.tooltip')
|
||||
var $tooltip = $(tooltip.getTipElement())
|
||||
assert.strictEqual($tooltip.children().text(), '7')
|
||||
done()
|
||||
})
|
||||
|
||||
$el.bootstrapTooltip('show')
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user