From ad9f542e93b0a9715227256c9b48c076a9914fda Mon Sep 17 00:00:00 2001 From: Aleksander Nowodzinski Date: Fri, 29 Mar 2013 15:52:07 +0100 Subject: [PATCH] Error thrown when destroying an instance in parallel with a mouseup event. --- plugins/clipboard/plugin.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/clipboard/plugin.js b/plugins/clipboard/plugin.js index b0c6afd6be..7d16a069d5 100644 --- a/plugins/clipboard/plugin.js +++ b/plugins/clipboard/plugin.js @@ -477,15 +477,24 @@ !preventBeforePasteEvent && fixCut( editor ); }); + var mouseupTimeout; + // Use editor.document instead of editable in non-IEs for observing mouseup // since editable won't fire the event if selection process started within // iframe and ended out of the editor (#9851). editable.attachListener( CKEDITOR.env.ie ? editable : editor.document.getDocumentElement(), 'mouseup', function() { - setTimeout( function() { + mouseupTimeout = setTimeout( function() { setToolbarStates(); }, 0 ); }); + // Make sure that deferred mouseup callback isn't executed after editor instance + // had been destroyed. This may happen when editor.destroy() is called in parallel + // with mouseup event (i.e. a button with onclick callback) (#10219). + editor.on( 'destroy', function() { + clearTimeout( mouseupTimeout ); + }); + editable.on( 'keyup', setToolbarStates ); }