Commit 3c190908 authored by Chris Rebert's avatar Chris Rebert
Browse files

Merge pull request #15988 from twbs/fix-15874

Hiding an uninitialized tooltip/popover no longer initializes it
parents 2f17289a 27bbc7db
4 merge requests!28721Hot test,!16605Test pull please ignore,!22103test,!25326Adjust examples
Showing with 26 additions and 2 deletions
+26 -2
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
var data = $this.data('bs.popover') var data = $this.data('bs.popover')
var options = typeof option == 'object' && option 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 (!data) $this.data('bs.popover', (data = new Popover(this, options)))
if (typeof option == 'string') data[option]() if (typeof option == 'string') data[option]()
}) })
......
...@@ -247,4 +247,16 @@ $(function () { ...@@ -247,4 +247,16 @@ $(function () {
}, new Error('`selector` option must be specified when initializing popover on the window.document object!')) }, 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')
})
}) })
...@@ -1168,4 +1168,16 @@ $(function () { ...@@ -1168,4 +1168,16 @@ $(function () {
}, new Error('`selector` option must be specified when initializing tooltip on the window.document object!')) }, 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')
})
}) })
...@@ -453,7 +453,7 @@ ...@@ -453,7 +453,7 @@
var data = $this.data('bs.tooltip') var data = $this.data('bs.tooltip')
var options = typeof option == 'object' && option 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 (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
if (typeof option == 'string') data[option]() if (typeof option == 'string') data[option]()
}) })
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment