1
0
Fork 0
mirror of https://github.com/twbs/bootstrap.git synced 2022-11-09 12:25:43 -05:00

Popover + Tooltip - fix error when content or title is a number

This commit is contained in:
Johann-S 2017-03-31 10:03:54 +02:00 committed by GitHub
parent cb4bc89fdf
commit 5142de7e59
3 changed files with 42 additions and 0 deletions

View file

@ -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,

View file

@ -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')
})
})

View file

@ -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')
})
})