From 0974267b8c2b137d563d36c2390b4491fb1e0309 Mon Sep 17 00:00:00 2001 From: Bardi Harborow Date: Tue, 1 Nov 2016 14:32:36 +1100 Subject: [PATCH] Move from $.proxy to es6 arrow functions. (#21049) --- js/src/alert.js | 2 +- js/src/carousel.js | 8 ++++---- js/src/modal.js | 10 ++++------ js/src/scrollspy.js | 2 +- js/src/tab.js | 4 +--- js/src/tooltip.js | 6 +++--- 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/js/src/alert.js b/js/src/alert.js index 0456c677df..27411e276c 100644 --- a/js/src/alert.js +++ b/js/src/alert.js @@ -117,7 +117,7 @@ const Alert = (($) => { } $(element) - .one(Util.TRANSITION_END, $.proxy(this._destroyElement, this, element)) + .one(Util.TRANSITION_END, (event) => this._destroyElement(element, event)) .emulateTransitionEnd(TRANSITION_DURATION) } diff --git a/js/src/carousel.js b/js/src/carousel.js index 54249039e6..17bfebc688 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -161,7 +161,7 @@ const Carousel = (($) => { if (this._config.interval && !this._isPaused) { this._interval = setInterval( - $.proxy(document.visibilityState ? this.nextWhenVisible : this.next, this), this._config.interval + (document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval ) } } @@ -219,14 +219,14 @@ const Carousel = (($) => { _addEventListeners() { if (this._config.keyboard) { $(this._element) - .on(Event.KEYDOWN, $.proxy(this._keydown, this)) + .on(Event.KEYDOWN, (event) => this._keydown(event)) } if (this._config.pause === 'hover' && !('ontouchstart' in document.documentElement)) { $(this._element) - .on(Event.MOUSEENTER, $.proxy(this.pause, this)) - .on(Event.MOUSELEAVE, $.proxy(this.cycle, this)) + .on(Event.MOUSEENTER, (event) => this.pause(event)) + .on(Event.MOUSELEAVE, (event) => this.cycle(event)) } } diff --git a/js/src/modal.js b/js/src/modal.js index 2526374287..a52dcb07fa 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -133,7 +133,7 @@ const Modal = (($) => { $(this._element).on( Event.CLICK_DISMISS, Selector.DATA_DISMISS, - $.proxy(this.hide, this) + (event) => this.hide(event) ) $(this._dialog).on(Event.MOUSEDOWN_DISMISS, () => { @@ -144,9 +144,7 @@ const Modal = (($) => { }) }) - this._showBackdrop( - $.proxy(this._showElement, this, relatedTarget) - ) + this._showBackdrop(() => this._showElement(relatedTarget)) } hide(event) { @@ -178,7 +176,7 @@ const Modal = (($) => { ($(this._element).hasClass(ClassName.FADE))) { $(this._element) - .one(Util.TRANSITION_END, $.proxy(this._hideModal, this)) + .one(Util.TRANSITION_END, (event) => this._hideModal(event)) .emulateTransitionEnd(TRANSITION_DURATION) } else { this._hideModal() @@ -284,7 +282,7 @@ const Modal = (($) => { _setResizeEvent() { if (this._isShown) { - $(window).on(Event.RESIZE, $.proxy(this._handleUpdate, this)) + $(window).on(Event.RESIZE, (event) => this._handleUpdate(event)) } else { $(window).off(Event.RESIZE) } diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index 604815f4e0..648173b33b 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -87,7 +87,7 @@ const ScrollSpy = (($) => { this._activeTarget = null this._scrollHeight = 0 - $(this._scrollElement).on(Event.SCROLL, $.proxy(this._process, this)) + $(this._scrollElement).on(Event.SCROLL, (event) => this._process(event)) this.refresh() this._process() diff --git a/js/src/tab.js b/js/src/tab.js index c625a010d5..012d2f76fc 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -156,9 +156,7 @@ const Tab = (($) => { && ((active && $(active).hasClass(ClassName.FADE)) || Boolean($(container).find(Selector.FADE_CHILD)[0])) - let complete = $.proxy( - this._transitionComplete, - this, + let complete = () => this._transitionComplete( element, active, isTransitioning, diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 90e782dc92..6c23b9f9dd 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -426,7 +426,7 @@ const Tooltip = (($) => { $(this.element).on( this.constructor.Event.CLICK, this.config.selector, - $.proxy(this.toggle, this) + (event) => this.toggle(event) ) } else if (trigger !== Trigger.MANUAL) { @@ -441,12 +441,12 @@ const Tooltip = (($) => { .on( eventIn, this.config.selector, - $.proxy(this._enter, this) + (event) => this._enter(event) ) .on( eventOut, this.config.selector, - $.proxy(this._leave, this) + (event) => this._leave(event) ) } })