Skip to content

Commit

Permalink
Improve the way of removing tether css
Browse files Browse the repository at this point in the history
  • Loading branch information
Johann-S committed Mar 27, 2017
1 parent 33e25f5 commit bf3a8a2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
16 changes: 12 additions & 4 deletions js/src/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,18 @@ const Tooltip = (($) => {

_cleanTipClass() {
const $tip = $(this.getTipElement())
if (this.config.toggle === 'tooltip') {
$tip.attr('class', 'tooltip fade')
} else {
$tip.attr('class', 'popover fade')
let tabClassStr = $tip.attr('class')
let tabClass = tabClassStr.split(' ')
let i = 0
while (tabClassStr.indexOf(CLASS_PREFIX) !== -1) {
if (tabClass[i].indexOf(CLASS_PREFIX) !== -1) {
$tip.removeClass(tabClass[i])
tabClassStr = $tip.attr('class')
tabClass = tabClassStr.split(' ')
i = 0
} else {
i++
}
}
}

Expand Down
5 changes: 3 additions & 2 deletions js/tests/unit/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -871,15 +871,16 @@ $(function () {
})

QUnit.test('should reset tip classes when hidden event triggered', function (assert) {
assert.expect(1)
assert.expect(2)
var done = assert.async()
var $el = $('<a href="#" rel="tooltip" title="Test tooltip"/>')
.appendTo('#qunit-fixture')
.bootstrapTooltip('show')
.on('hidden.bs.tooltip', function () {
var tooltip = $el.data('bs.tooltip')
var $tooltip = $(tooltip.getTipElement())
assert.ok($tooltip[0].classList.length === 2)
assert.ok($tooltip.hasClass('tooltip'))
assert.ok($tooltip.hasClass('fade'))
done()
})

Expand Down

0 comments on commit bf3a8a2

Please sign in to comment.