Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions js/src/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -565,11 +565,11 @@ class Tooltip extends BaseComponent {
}
}

if (typeof config.title === 'number') {
if (typeof config.title === 'number' || typeof config.title === 'boolean') {
config.title = config.title.toString()
}

if (typeof config.content === 'number') {
if (typeof config.content === 'number' || typeof config.content === 'boolean') {
config.content = config.content.toString()
}

Expand Down
11 changes: 11 additions & 0 deletions js/tests/unit/popover.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ describe('Popover', () => {
})
})

describe('config', () => {
it('should accept "true"/"false" string content from data-bs-content as literal strings', () => {
fixtureEl.innerHTML = '<a href="#" title="Popover" data-bs-content="true">BS</a>'

const popoverEl = fixtureEl.querySelector('a')
const popover = new Popover(popoverEl)

expect(popover._config.content).toEqual('true')
})
})

describe('show', () => {
it('should toggle a popover after show', () => {
return new Promise(resolve => {
Expand Down
13 changes: 13 additions & 0 deletions js/tests/unit/tooltip.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ describe('Tooltip', () => {
expect(tooltip._config.content).toEqual('7')
})

it('should convert title and content to string if booleans', () => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip"></a>'

const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl, {
title: true,
content: false
})

expect(tooltip._config.title).toEqual('true')
expect(tooltip._config.content).toEqual('false')
})

it('should enable selector delegation', () => {
return new Promise(resolve => {
fixtureEl.innerHTML = '<div></div>'
Expand Down