Skip to content

Commit

Permalink
Move from $.proxy to es6 arrow functions. (twbs#21049)
Browse files Browse the repository at this point in the history
  • Loading branch information
bardiharborow authored and mdo committed Nov 1, 2016
1 parent d6cc0e0 commit 0974267
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion js/src/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
8 changes: 4 additions & 4 deletions js/src/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
}
Expand Down Expand Up @@ -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))
}
}

Expand Down
10 changes: 4 additions & 6 deletions js/src/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, () => {
Expand All @@ -144,9 +144,7 @@ const Modal = (($) => {
})
})

this._showBackdrop(
$.proxy(this._showElement, this, relatedTarget)
)
this._showBackdrop(() => this._showElement(relatedTarget))
}

hide(event) {
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion js/src/scrollspy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 1 addition & 3 deletions js/src/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions js/src/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
)
}
})
Expand Down

0 comments on commit 0974267

Please sign in to comment.