Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
Textinput autogrow: Detach transitionend event handler to prevent leak
Browse files Browse the repository at this point in the history
Fixes gh-6697
  • Loading branch information
Gabriel Schulhof committed Jan 13, 2014
1 parent dfc5d32 commit 4d88307
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions js/widgets/forms/autogrow.js
Expand Up @@ -54,15 +54,30 @@ define( [
// content has become visible, but the collapsible is still collapsed, so
// the autogrow textarea is still not visible.
_handleShow: function( event ) {
var eventNs = ".textinputAutogrow" + this.uuid,
eventName = "transitionend" + eventNs +
" webkitTransitionEnd" + eventNs +
" oTransitionEnd" + eventNs;

if ( $.contains( event.target, this.element[ 0 ] ) &&
this.element.is( ":visible" ) ) {

if ( event.type !== "popupbeforeposition" ) {
this.element
.addClass( "ui-textinput-autogrow-resize" )
.one( "transitionend webkitTransitionEnd oTransitionEnd",

// Remove previous events in case none of them fired
.off( eventName )

// Listen for the first event related to the transition ending
.one( eventName,
$.proxy( function() {
this.element.removeClass( "ui-textinput-autogrow-resize" );

this.element

// Remove events not emitted by this browser
.off( eventName )
.removeClass( "ui-textinput-autogrow-resize" );
}, this ) );
}
this._prepareHeightUpdate();
Expand Down

0 comments on commit 4d88307

Please sign in to comment.