diff options
| author | Pierre Vanduynslager <[email protected]> | 2017-03-28 17:43:16 -0400 |
|---|---|---|
| committer | Johann-S <[email protected]> | 2017-03-28 23:43:15 +0200 |
| commit | 48c5efa4c3c439d8720b8475ec3e372c6974a12a (patch) | |
| tree | 927c262f444f4aaeb0f598cf35ab7b1b385ae76a /js/src/tooltip.js | |
| parent | ce0e2f8e76dade4b6ec9d6eb541c6988739f0653 (diff) | |
| download | bootstrap-48c5efa4c3c439d8720b8475ec3e372c6974a12a.tar.xz bootstrap-48c5efa4c3c439d8720b8475ec3e372c6974a12a.zip | |
Fix JS components console error "Error: <Component> is transitioning"
Diffstat (limited to 'js/src/tooltip.js')
| -rw-r--r-- | js/src/tooltip.js | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/js/src/tooltip.js b/js/src/tooltip.js index fe913e660..5fd4987b9 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -124,12 +124,11 @@ const Tooltip = (($) => { constructor(element, config) { // private - this._isEnabled = true - this._timeout = 0 - this._hoverState = '' - this._activeTrigger = {} - this._isTransitioning = false - this._tether = null + this._isEnabled = true + this._timeout = 0 + this._hoverState = '' + this._activeTrigger = {} + this._tether = null // protected this.element = element @@ -250,9 +249,6 @@ const Tooltip = (($) => { const showEvent = $.Event(this.constructor.Event.SHOW) if (this.isWithContent() && this._isEnabled) { - if (this._isTransitioning) { - throw new Error('Tooltip is transitioning') - } $(this.element).trigger(showEvent) const isInTheDom = $.contains( @@ -284,9 +280,11 @@ const Tooltip = (($) => { const container = this.config.container === false ? document.body : $(this.config.container) - $(tip) - .data(this.constructor.DATA_KEY, this) - .appendTo(container) + $(tip).data(this.constructor.DATA_KEY, this) + + if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) { + $(tip).appendTo(container) + } $(this.element).trigger(this.constructor.Event.INSERTED) @@ -308,8 +306,7 @@ const Tooltip = (($) => { const complete = () => { const prevHoverState = this._hoverState - this._hoverState = null - this._isTransitioning = false + this._hoverState = null $(this.element).trigger(this.constructor.Event.SHOWN) @@ -319,7 +316,6 @@ const Tooltip = (($) => { } if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) { - this._isTransitioning = true $(this.tip) .one(Util.TRANSITION_END, complete) .emulateTransitionEnd(Tooltip._TRANSITION_DURATION) @@ -333,9 +329,6 @@ const Tooltip = (($) => { hide(callback) { const tip = this.getTipElement() const hideEvent = $.Event(this.constructor.Event.HIDE) - if (this._isTransitioning) { - throw new Error('Tooltip is transitioning') - } const complete = () => { if (this._hoverState !== HoverState.SHOW && tip.parentNode) { tip.parentNode.removeChild(tip) @@ -344,7 +337,6 @@ const Tooltip = (($) => { this._cleanTipClass() this.element.removeAttribute('aria-describedby') $(this.element).trigger(this.constructor.Event.HIDDEN) - this._isTransitioning = false this.cleanupTether() if (callback) { @@ -366,7 +358,7 @@ const Tooltip = (($) => { if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) { - this._isTransitioning = true + $(tip) .one(Util.TRANSITION_END, complete) .emulateTransitionEnd(TRANSITION_DURATION) |
