mirror of
https://github.com/twbs/bootstrap.git
synced 2025-02-26 23:54:23 +01:00
fix(tooltip): get tip on placement change
This commit is contained in:
parent
4112df4125
commit
e57a2f244b
@ -660,9 +660,11 @@ const Tooltip = (($) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_handlePopperPlacementChange(data) {
|
_handlePopperPlacementChange(popperData) {
|
||||||
|
const popperInstance = popperData.instance
|
||||||
|
this.tip = popperInstance.popper
|
||||||
this._cleanTipClass()
|
this._cleanTipClass()
|
||||||
this.addAttachmentClass(this._getAttachment(data.placement))
|
this.addAttachmentClass(this._getAttachment(popperData.placement))
|
||||||
}
|
}
|
||||||
|
|
||||||
_fixTransition() {
|
_fixTransition() {
|
||||||
|
@ -943,4 +943,27 @@ $(function () {
|
|||||||
|
|
||||||
assert.ok(tooltip._popper === null)
|
assert.ok(tooltip._popper === null)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
QUnit.test('should use Popper.js to get the tip on placement change', function (assert) {
|
||||||
|
assert.expect(1)
|
||||||
|
|
||||||
|
var $tooltip = $('<a href="#" rel="tooltip" data-trigger="click" title="Another tooltip"/>')
|
||||||
|
.appendTo('#qunit-fixture')
|
||||||
|
.bootstrapTooltip()
|
||||||
|
|
||||||
|
var $tipTest = $('<div class="bs-tooltip" />')
|
||||||
|
.appendTo('#qunit-fixture')
|
||||||
|
|
||||||
|
var tooltip = $tooltip.data('bs.tooltip')
|
||||||
|
tooltip.tip = null
|
||||||
|
|
||||||
|
tooltip._handlePopperPlacementChange({
|
||||||
|
instance: {
|
||||||
|
popper: $tipTest[0]
|
||||||
|
},
|
||||||
|
placement: 'auto'
|
||||||
|
})
|
||||||
|
|
||||||
|
assert.ok(tooltip.tip === $tipTest[0])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user