diff --git a/src/components/main.jsx b/src/components/main.jsx index 5b4d7cc59..e9a097dc8 100644 --- a/src/components/main.jsx +++ b/src/components/main.jsx @@ -101,12 +101,12 @@ class UI extends React.Component { // debounce it, when the handler is being invoked, the target might be no more part // of the editor's UI - onActionPerformed causes re-render. - this._mousedownListener = event => { + this._mousedownListener = (event) => { this._setUIHidden(event.target); }; this._keyDownListener = CKEDITOR.tools.debounce( - _event => { + (_event) => { this._setUIHidden(document.activeElement); }, this.props.eventsDelay, @@ -201,7 +201,7 @@ class UI extends React.Component { } else { const toolbarNames = Array.prototype.slice .call(toolbarsNodeList) - .map(toolbar => { + .map((toolbar) => { return toolbar.getAttribute('aria-label'); }); @@ -229,7 +229,10 @@ class UI extends React.Component { } if (this._keyDownListener) { - this._keyDownListener.detach(); + if (this._keyDownListener.detach) { + this._keyDownListener.detach(); + } + document.removeEventListener('keydown', this._keyDownListener); } } @@ -248,11 +251,11 @@ class UI extends React.Component { return null; } - let toolbars = Object.keys(this.props.toolbars).map(toolbar => { + let toolbars = Object.keys(this.props.toolbars).map((toolbar) => { return AlloyEditor.Toolbars[toolbar] || window[toolbar]; }); - toolbars = this.filterExclusive(toolbars).map(toolbar => { + toolbars = this.filterExclusive(toolbars).map((toolbar) => { const props = this.mergeExclusiveProps( { config: this.props.toolbars[toolbar.key], diff --git a/src/core/uicore.js b/src/core/uicore.js index 9fac979de..afa3e1c72 100644 --- a/src/core/uicore.js +++ b/src/core/uicore.js @@ -76,7 +76,7 @@ if (!CKEDITOR.plugins.get('ae_uicore')) { ? editor.config.uicore.timeout : 50; - const handleUI = CKEDITOR.tools.debounce(event => { + const handleUI = CKEDITOR.tools.debounce((event) => { ariaState = []; if ( @@ -95,11 +95,11 @@ if (!CKEDITOR.plugins.get('ae_uicore')) { } }, uiTasksTimeout); - const handleAria = CKEDITOR.tools.debounce(_event => { + const handleAria = CKEDITOR.tools.debounce((_event) => { ariaElement.innerHTML = ariaState.join('. '); }, uiTasksTimeout); - const handleMouseLeave = CKEDITOR.tools.debounce(event => { + const handleMouseLeave = CKEDITOR.tools.debounce((event) => { const aeUINodes = document.querySelectorAll('.ae-ui'); let found; @@ -116,7 +116,7 @@ if (!CKEDITOR.plugins.get('ae_uicore')) { } }, uiTasksTimeout); - editor.on('ariaUpdate', event => { + editor.on('ariaUpdate', (event) => { // handleAria is debounced function, so if it is being called multiple times, it will // be canceled until some time passes. // For that reason here we explicitly append the current message to the list of messages @@ -134,7 +134,7 @@ if (!CKEDITOR.plugins.get('ae_uicore')) { const focusHandler = editable.attachListener( editable, 'focus', - event => { + (event) => { focusHandler.removeListener(); editable.attachListener(editable, 'keyup', handleUI); @@ -150,10 +150,12 @@ if (!CKEDITOR.plugins.get('ae_uicore')) { ); }); - editor.on('destroy', _event => { + editor.on('destroy', (_event) => { ariaElement.parentNode.removeChild(ariaElement); - handleUI.detach(); + if (handleUI.detach) { + handleUI.detach(); + } }); },