Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hiding an uninitialized tooltip/popover no longer initializes it #15988

Merged
merged 1 commit into from
Mar 4, 2015
Merged
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
2 changes: 1 addition & 1 deletion js/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
var data = $this.data('bs.popover')
var options = typeof option == 'object' && option

if (!data && option == 'destroy') return
if (!data && /destroy|hide/.test(option)) return
if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
if (typeof option == 'string') data[option]()
})
Expand Down
12 changes: 12 additions & 0 deletions js/tests/unit/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,16 @@ $(function () {
}, new Error('`selector` option must be specified when initializing popover on the window.document object!'))
})

QUnit.test('should do nothing when an attempt is made to hide an uninitialized popover', function (assert) {
assert.expect(1)

var $popover = $('<span data-toggle="popover" data-title="some title" data-content="some content">some text</span>')
.appendTo('#qunit-fixture')
.on('hidden.bs.popover shown.bs.popover', function () {
assert.ok(false, 'should not fire any popover events')
})
.bootstrapPopover('hide')
assert.strictEqual($popover.data('bs.popover'), undefined, 'should not initialize the popover')
})

})
12 changes: 12 additions & 0 deletions js/tests/unit/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -1168,4 +1168,16 @@ $(function () {
}, new Error('`selector` option must be specified when initializing tooltip on the window.document object!'))
})

QUnit.test('should do nothing when an attempt is made to hide an uninitialized tooltip', function (assert) {
assert.expect(1)

var $tooltip = $('<span data-toggle="tooltip" title="some tip">some text</span>')
.appendTo('#qunit-fixture')
.on('hidden.bs.tooltip shown.bs.tooltip', function () {
assert.ok(false, 'should not fire any tooltip events')
})
.bootstrapTooltip('hide')
assert.strictEqual($tooltip.data('bs.tooltip'), undefined, 'should not initialize the tooltip')
})

})
2 changes: 1 addition & 1 deletion js/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@
var data = $this.data('bs.tooltip')
var options = typeof option == 'object' && option

if (!data && option == 'destroy') return
if (!data && /destroy|hide/.test(option)) return
if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
if (typeof option == 'string') data[option]()
})
Expand Down