aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorChris Rebert <[email protected]>2015-01-05 14:22:49 -0800
committerChris Rebert <[email protected]>2015-01-05 14:22:49 -0800
commitf6a837cbf1eb24429a4356ef95d7a52e6da35b43 (patch)
treee9c0e0f3723b6c8d32a9bac8ed24111f21d667cd /js
parent08410280091ff1ef77e110c1e5e29eb8f3653a84 (diff)
downloadbootstrap-f6a837cbf1eb24429a4356ef95d7a52e6da35b43.tar.xz
bootstrap-f6a837cbf1eb24429a4356ef95d7a52e6da35b43.zip
Make $(document).tooltip({...}) without a `selector` throw an error
Closes #15484
Diffstat (limited to 'js')
-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--;) {