aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorAlexander Schmitz <arschmitz@gmail.com>2016-09-12 10:26:24 -0400
committerAlexander Schmitz <arschmitz@gmail.com>2016-09-13 15:11:34 -0400
commit89af4c292eaa5fc1c83437ca71085264dcbef34a (patch)
treec9200b263d00490bc0533637627bc7e0c0148d8f /ui
parent7b7b9b6d8616873c8da22043d499ffde376a2b12 (diff)
downloadjquery-ui-89af4c292eaa5fc1c83437ca71085264dcbef34a.tar.gz
jquery-ui-89af4c292eaa5fc1c83437ca71085264dcbef34a.zip
Widget: Untrack classes elements when they are removed from the DOM
Fixes #15043 Closes gh-1744
Diffstat (limited to 'ui')
-rw-r--r--ui/widget.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/ui/widget.js b/ui/widget.js
index 06a3ce88e..a3922675f 100644
--- a/ui/widget.js
+++ b/ui/widget.js
@@ -514,6 +514,10 @@ $.Widget.prototype = {
}
}
+ this._on( options.element, {
+ "remove": "_untrackClassesElement"
+ } );
+
if ( options.keys ) {
processClassString( options.keys.match( /\S+/g ) || [], true );
}
@@ -524,6 +528,15 @@ $.Widget.prototype = {
return full.join( " " );
},
+ _untrackClassesElement: function( event ) {
+ var that = this;
+ $.each( that.classesElementLookup, function( key, value ) {
+ if ( $.inArray( event.target, value ) !== -1 ) {
+ that.classesElementLookup[ key ] = $( value.not( event.target ).get() );
+ }
+ } );
+ },
+
_removeClass: function( element, keys, extra ) {
return this._toggleClass( element, keys, extra, false );
},