diff options
Diffstat (limited to 'js/src/tooltip.js')
| -rw-r--r-- | js/src/tooltip.js | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 151cd6f51..b0eec1abc 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -1,15 +1,25 @@ +/* global Tether */ + import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0): tooltip.js + * Bootstrap (v4.0.0-alpha): tooltip.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ const Tooltip = (($) => { + /** + * Check for Tether dependency + * Tether - http://github.hubspot.com/tether/ + */ + if (window.Tether === undefined) { + throw new Error('Bootstrap tooltips require Tether (http://github.hubspot.com/tether/)') + } + /** * ------------------------------------------------------------------------ @@ -18,7 +28,7 @@ const Tooltip = (($) => { */ const NAME = 'tooltip' - const VERSION = '4.0.0' + const VERSION = '4.0.0-alpha' const DATA_KEY = 'bs.tooltip' const EVENT_KEY = `.${DATA_KEY}` const JQUERY_NO_CONFLICT = $.fn[NAME] @@ -270,12 +280,13 @@ const Tooltip = (($) => { this._tether = new Tether({ attachment, - element : tip, - target : this.element, - classes : TetherClass, - classPrefix : CLASS_PREFIX, - offset : this.config.offset, - constraints : this.config.constraints + element : tip, + target : this.element, + classes : TetherClass, + classPrefix : CLASS_PREFIX, + offset : this.config.offset, + constraints : this.config.constraints, + addTargetClasses: false }) Util.reflow(tip) @@ -398,12 +409,6 @@ const Tooltip = (($) => { cleanupTether() { if (this._tether) { this._tether.destroy() - - // clean up after tether's junk classes - // remove after they fix issue - // (https://github.com/HubSpot/tether/issues/36) - $(this.element).removeClass(this._removeTetherClasses) - $(this.tip).removeClass(this._removeTetherClasses) } } @@ -457,12 +462,6 @@ const Tooltip = (($) => { } } - _removeTetherClasses(i, css) { - return ((css.baseVal || css).match( - new RegExp(`(^|\\s)${CLASS_PREFIX}-\\S+`, 'g')) || [] - ).join(' ') - } - _fixTitle() { let titleType = typeof this.element.getAttribute('data-original-title') if (this.element.getAttribute('title') || @@ -622,6 +621,9 @@ const Tooltip = (($) => { } if (typeof config === 'string') { + if (data[config] === undefined) { + throw new Error(`No method named "${config}"`) + } data[config]() } }) |
