From 89af4c292eaa5fc1c83437ca71085264dcbef34a Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Mon, 12 Sep 2016 10:26:24 -0400 Subject: Widget: Untrack classes elements when they are removed from the DOM Fixes #15043 Closes gh-1744 --- ui/widget.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ui') 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 ); }, -- cgit v1.2.3