Closes #16219.
assert.strictEqual($popover.data('bs.popover'), undefined, 'should not initialize the popover')
})
+ QUnit.test('should throw an error when template contains multiple top-level elements', function (assert) {
+ assert.expect(1)
+ assert.throws(function () {
+ $('<span data-toggle="popover" data-title="some title" data-content="some content">some text</span>')
+ .appendTo('#qunit-fixture')
+ .bootstrapPopover({ template: '<div>Foo</div><div>Bar</div>' })
+ .bootstrapPopover('show')
+ }, new Error('popover `template` option must consist of exactly 1 top-level element!'))
+ })
+
QUnit.test('should fire inserted event', function (assert) {
assert.expect(2)
var done = assert.async()
})
.bootstrapPopover('show')
})
+
})
assert.strictEqual($tooltip.data('bs.tooltip'), undefined, 'should not initialize the tooltip')
})
+ QUnit.test('should throw an error when template contains multiple top-level elements', function (assert) {
+ assert.expect(1)
+ assert.throws(function () {
+ $('<a href="#" data-toggle="tooltip" title="Another tooltip"></a>')
+ .appendTo('#qunit-fixture')
+ .bootstrapTooltip({ template: '<div>Foo</div><div>Bar</div>' })
+ .bootstrapTooltip('show')
+ }, new Error('tooltip `template` option must consist of exactly 1 top-level element!'))
+ })
+
})
}
Tooltip.prototype.tip = function () {
- return (this.$tip = this.$tip || $(this.options.template))
+ if (!this.$tip) {
+ this.$tip = $(this.options.template)
+ if (this.$tip.length != 1) {
+ throw new Error(this.type + ' `template` option must consist of exactly 1 top-level element!')
+ }
+ }
+ return this.$tip
}
Tooltip.prototype.arrow = function () {