aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/tests/unit/popover.js7
-rw-r--r--js/tests/unit/tooltip.js6
-rw-r--r--js/tooltip.js4
3 files changed, 17 insertions, 0 deletions
diff --git a/js/tests/unit/popover.js b/js/tests/unit/popover.js
index e1a2edef7..b18366a7e 100644
--- a/js/tests/unit/popover.js
+++ b/js/tests/unit/popover.js
@@ -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!'))
+ })
+
})
diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js
index 2264ca372..32892f12b 100644
--- a/js/tests/unit/tooltip.js
+++ b/js/tests/unit/tooltip.js
@@ -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!'))
+ })
+
})
diff --git a/js/tooltip.js b/js/tooltip.js
index a1140d247..b47c010f3 100644
--- a/js/tooltip.js
+++ b/js/tooltip.js
@@ -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 window.Document && !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--;) {