]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Make $(document).tooltip({...}) without a `selector` throw an error
authorChris Rebert <code@rebertia.com>
Mon, 5 Jan 2015 22:22:49 +0000 (14:22 -0800)
committerChris Rebert <code@rebertia.com>
Mon, 5 Jan 2015 22:22:49 +0000 (14:22 -0800)
Closes #15484

js/tests/unit/popover.js
js/tests/unit/tooltip.js
js/tooltip.js

index e1a2edef71b7f9b2a9142845bc810d0055484315..b18366a7eae2779b18978f0f69a3b0468c329937 100644 (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!'))
+  })
+
 })
index 2264ca3727fe851d9cb1a2432987b301f53e6cd2..32892f12bac9d11d3e3bf8aa1c7fc04153520c76 100644 (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!'))
+  })
+
 })
index a1140d24793821e775f22515b9e3a494f5a6be94..b47c010f37c824ba4dd70bb2f548dfda3988b5d0 100644 (file)
     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--;) {