diff --git a/js/src/tooltip.js b/js/src/tooltip.js
index 097477f7a1a8..bcb044a3b3bf 100644
--- a/js/src/tooltip.js
+++ b/js/src/tooltip.js
@@ -186,14 +186,13 @@ class Tooltip extends BaseComponent {
throw new Error('Please use show on visible elements')
}
- if (!(this._isWithContent() && this._isEnabled)) {
+ if (!((this._isWithContent() || this._newContent !== null) && this._isEnabled)) {
return
}
const showEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOW))
const shadowRoot = findShadowRoot(this._element)
const isInTheDom = (shadowRoot || this._element.ownerDocument.documentElement).contains(this._element)
-
if (showEvent.defaultPrevented || !isInTheDom) {
return
}
diff --git a/js/tests/unit/popover.spec.js b/js/tests/unit/popover.spec.js
index 1c81ba79279c..a1a86a0d9e80 100644
--- a/js/tests/unit/popover.spec.js
+++ b/js/tests/unit/popover.spec.js
@@ -56,6 +56,26 @@ describe('Popover', () => {
})
describe('show', () => {
+ it('should show a popover with no content after setContent', () => {
+ return new Promise(resolve => {
+ fixtureEl.innerHTML = 'BS twitter'
+
+ const popoverEl = fixtureEl.querySelector('a')
+ const popover = Popover.getOrCreateInstance(popoverEl)
+
+ popoverEl.addEventListener('shown.bs.popover', () => {
+ expect(document.querySelector('.popover')).not.toBeNull()
+ resolve()
+ })
+
+ popover.setContent({
+ '.popover-body': 'some content'
+ })
+
+ popover.show()
+ })
+ })
+
it('should toggle a popover after show', () => {
return new Promise(resolve => {
fixtureEl.innerHTML = 'BS twitter'