0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-11-28 10:24:19 +01:00

Merge pull request #15496 from twbs/15484-alternative

Make $(document).tooltip({...}) without a `selector` throw an error
This commit is contained in:
Chris Rebert 2015-01-28 11:05:40 -08:00
commit cd4467b194
3 changed files with 17 additions and 0 deletions

View File

@ -225,4 +225,11 @@ $(function () {
})
.bootstrapPopover('show')
})
test('should throw an error when initializing popover on the document object without specifying a delegation selector', function () {
throws(function () {
$(document).bootstrapPopover({ title: 'What am I on?', content: 'My selector is missing' })
}, new Error('`selector` option must be specified when initializing popover on the window.document object!'))
})
})

View File

@ -1107,4 +1107,10 @@ $(function () {
$element.bootstrapTooltip('show')
})
test('should throw an error when initializing tooltip on the document object without specifying a delegation selector', function () {
throws(function () {
$(document).bootstrapTooltip({ title: 'What am I on?' })
}, new Error('`selector` option must be specified when initializing tooltip on the window.document object!'))
})
})

View File

@ -52,6 +52,10 @@
this.options = this.getOptions(options)
this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport)
if (this.$element[0] instanceof document.constructor && !this.options.selector) {
throw new Error('`selector` option must be specified when initializing ' + this.type + ' on the window.document object!');
}
var triggers = this.options.trigger.split(' ')
for (var i = triggers.length; i--;) {