this._activeTrigger = {}
this._popper = null
this._templateFactory = null
+ this._newContent = null
// Protected
this.tip = null
return
}
+ // todo v6 remove this OR make it optional
+ if (this.tip) {
+ this.tip.remove()
+ this.tip = null
+ }
+
const tip = this._getTipElement()
this._element.setAttribute('aria-describedby', tip.getAttribute('id'))
if (this._popper) {
this._popper.update()
} else {
- this._createPopper(tip)
+ this._popper = this._createPopper(tip)
}
tip.classList.add(CLASS_NAME_SHOW)
_getTipElement() {
if (!this.tip) {
- this.tip = this._createTipElement(this._getContentForTemplate())
+ this.tip = this._createTipElement(this._newContent || this._getContentForTemplate())
}
return this.tip
}
setContent(content) {
- let isShown = false
- if (this.tip) {
- isShown = this._isShown()
+ this._newContent = content
+ if (this._isShown()) {
this.tip.remove()
this.tip = null
- }
-
- this._disposePopper()
- this.tip = this._createTipElement(content)
-
- if (isShown) {
+ this._disposePopper()
this.show()
}
}
}
_getTitle() {
- return this._config.title
+ return this._resolvePossibleFunction(this._config.title) || this._config.originalTitle
}
// Private
this._config.placement.call(this, tip, this._element) :
this._config.placement
const attachment = AttachmentMap[placement.toUpperCase()]
- this._popper = Popper.createPopper(this._element, tip, this._getPopperConfig(attachment))
+ return Popper.createPopper(this._element, tip, this._getPopperConfig(attachment))
}
_getOffset() {
}
config.originalTitle = this._element.getAttribute('title') || ''
- config.title = this._resolvePossibleFunction(config.title) || config.originalTitle
if (typeof config.title === 'number') {
config.title = config.title.toString()
}
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
- expect(tooltip._config.title).toEqual('Another tooltip')
+ expect(tooltip._getTitle()).toEqual('Another tooltip')
})
})
}, 100)
setTimeout(() => {
- expect(insertedFunc).toHaveBeenCalledTimes(1)
+ expect(insertedFunc).toHaveBeenCalledTimes(2)
resolve()
}, 200)
}, 0)
tooltip.setContent({ '.tooltip-inner': 'foo' })
expect(tip()).not.toHaveClass('show')
+ tooltip.show()
expect(tip().querySelector('.tooltip-inner').textContent).toEqual('foo')
})
})
tooltip.setContent({ '.tooltip': { 0: childContent, jquery: 'jQuery' } })
+ tooltip.show()
expect(childContent.parentNode).toEqual(tooltip._getTipElement())
})