From 09bc69678decbeea98dbe3fd38b594f7bbec533d Mon Sep 17 00:00:00 2001 From: "kyuwoo.choi" Date: Mon, 23 Jul 2018 16:03:38 +0900 Subject: [PATCH] fix: replace IE10 incompatible functions --- src/js/editor.js | 4 ++-- src/js/ui/codeBlockLanguagesCombo.js | 6 +++--- src/js/ui/popupAddLink.js | 9 +++++---- src/js/ui/popupCodeBlockEditor.js | 2 +- src/js/ui/scrollSyncSplit.js | 10 +++++----- test/unit/codeMirrorExt.spec.js | 2 +- test/unit/ui/popupAddLink.spec.js | 4 ++-- 7 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/js/editor.js b/src/js/editor.js index 4e4fc82364..af3f0ecf7a 100644 --- a/src/js/editor.js +++ b/src/js/editor.js @@ -508,10 +508,10 @@ class ToastUIEditor { height(height) { if (util.isExisty(height)) { if (height === 'auto') { - this.options.el.classList.add('auto-height'); + $(this.options.el).addClass('auto-height'); this.minHeight(this.minHeight()); } else { - this.options.el.classList.remove('auto-height'); + $(this.options.el).removeClass('auto-height'); this.minHeight(height); } if (util.isNumber(height)) { diff --git a/src/js/ui/codeBlockLanguagesCombo.js b/src/js/ui/codeBlockLanguagesCombo.js index c84d4a0e23..c3a11c1d4d 100644 --- a/src/js/ui/codeBlockLanguagesCombo.js +++ b/src/js/ui/codeBlockLanguagesCombo.js @@ -49,7 +49,7 @@ class CodeBlockLanguagesCombo { */ _showPopupCodeBlockLanguages() { const clientRect = this._inputLanguage.getBoundingClientRect(); - this._wrapper.classList.toggle('active', true); + $(this._wrapper).toggleClass('active', true); this.active = true; this._popupCodeBlockLanguages = this._eventManager.emitReduce('openPopupCodeBlockLanguages', { @@ -69,7 +69,7 @@ class CodeBlockLanguagesCombo { _toggleFocus() { const inputLanguage = this._inputLanguage; - if (this._wrapper.classList.contains('active')) { + if ($(this._wrapper).hasClass('active')) { inputLanguage.blur(); } else { inputLanguage.focus(); @@ -77,7 +77,7 @@ class CodeBlockLanguagesCombo { } _onFocusOut() { - this._wrapper.classList.toggle('active', false); + $(this._wrapper).toggleClass('active', false); this._inputLanguage.value = this._prevStoredLanguage; this._hidePopupCodeBlockLanguages(); } diff --git a/src/js/ui/popupAddLink.js b/src/js/ui/popupAddLink.js index c3de964eb7..ad81255843 100644 --- a/src/js/ui/popupAddLink.js +++ b/src/js/ui/popupAddLink.js @@ -2,6 +2,7 @@ * @fileoverview Implements PopupAddLink * @author NHN Ent. FE Development Lab */ +import $ from 'jquery'; import util from 'tui-code-snippet'; import LayerPopup from './layerpopup'; @@ -129,12 +130,12 @@ class PopupAddLink extends LayerPopup { this._clearValidationStyle(); if (linkText.length < 1) { - this._inputText.classList.add('wrong'); + $(this._inputText).addClass('wrong'); return; } if (url.length < 1) { - this._inputURL.classList.add('wrong'); + $(this._inputURL).addClass('wrong'); return; } @@ -157,8 +158,8 @@ class PopupAddLink extends LayerPopup { } _clearValidationStyle() { - this._inputURL.classList.remove('wrong'); - this._inputText.classList.remove('wrong'); + $(this._inputURL).removeClass('wrong'); + $(this._inputText).removeClass('wrong'); } _resetInputs() { diff --git a/src/js/ui/popupCodeBlockEditor.js b/src/js/ui/popupCodeBlockEditor.js index 43db57f2b2..0c80c5f713 100644 --- a/src/js/ui/popupCodeBlockEditor.js +++ b/src/js/ui/popupCodeBlockEditor.js @@ -139,7 +139,7 @@ class PopupCodeBlockEditor extends LayerPopup { _createCodeBlockEditor() { const codeMirrorWrapper = document.createElement('div'); - codeMirrorWrapper.classList.add(`${CLASS_PREFIX}editor-wrapper`); + codeMirrorWrapper.className = `${CLASS_PREFIX}editor-wrapper`; this._codeBlockEditor = new CodeBlockEditor(codeMirrorWrapper, this.eventManager); diff --git a/src/js/ui/scrollSyncSplit.js b/src/js/ui/scrollSyncSplit.js index a966ec05ba..bd9a1dbcf2 100644 --- a/src/js/ui/scrollSyncSplit.js +++ b/src/js/ui/scrollSyncSplit.js @@ -121,7 +121,7 @@ class ScrollSyncSplit { $(contentElement).off(EVENT_REQUIRE_SCROLL_INTO_VIEW); this._contentWrapper.removeChild(contentElement); } - element.classList.add(CLASS_CONTENT[side]); + $(element).addClass(CLASS_CONTENT[side]); this._contentWrapper.appendChild(element); $(element).on(EVENT_REQUIRE_SCROLL_INTO_VIEW, ev => this._requireScrollIntoView(ev)); $(element).on(EVENT_REQUIRE_SCROLL_SYNC, () => this.sync()); @@ -160,7 +160,7 @@ class ScrollSyncSplit { * @memberof ScrollSyncSplit */ toggleScrollSync() { - this._el.classList.toggle(CLASS_SCROLL_SYNC); + $(this._el).toggleClass(CLASS_SCROLL_SYNC); } setSplitView(activate) { @@ -172,7 +172,7 @@ class ScrollSyncSplit { * @memberof ScrollSyncSplit */ toggleSplitView() { - this._el.classList.toggle(CLASS_SINGLE_CONTENT); + $(this._el).toggleClass(CLASS_SINGLE_CONTENT); } /** @@ -181,7 +181,7 @@ class ScrollSyncSplit { * @memberof ScrollSyncSplit */ isScrollSynced() { - return this._el.classList.contains(CLASS_SCROLL_SYNC); + return $(this._el).hasClass(CLASS_SCROLL_SYNC); } /** @@ -190,7 +190,7 @@ class ScrollSyncSplit { * @memberof ScrollSyncSplit */ isSplitView() { - return !this._el.classList.contains(CLASS_SINGLE_CONTENT); + return !$(this._el).hasClass(CLASS_SINGLE_CONTENT); } /** diff --git a/test/unit/codeMirrorExt.spec.js b/test/unit/codeMirrorExt.spec.js index 9de7ec7d51..5a8ec1d9ea 100644 --- a/test/unit/codeMirrorExt.spec.js +++ b/test/unit/codeMirrorExt.spec.js @@ -123,7 +123,7 @@ describe('CodeMirrorExt', () => { const wrapper = codeMirrorExt.getWrapperElement(); expect(wrapper).toEqual(jasmine.any(HTMLElement)); - expect(wrapper.classList.contains('CodeMirror')); + expect($(wrapper.classList).hasClass('CodeMirror')); }); describe('get, set scrollTop', () => { diff --git a/test/unit/ui/popupAddLink.spec.js b/test/unit/ui/popupAddLink.spec.js index 0a3077e45e..34e13d0092 100644 --- a/test/unit/ui/popupAddLink.spec.js +++ b/test/unit/ui/popupAddLink.spec.js @@ -131,7 +131,7 @@ describe('PopupAddLink', () => { $(okButton).trigger('click'); expect(handler).not.toHaveBeenCalled(); - expect(urlInput.classList.contains('wrong')).toBe(true); + expect($(urlInput).hasClass('wrong')).toBe(true); }); it('should not emit AddLink and style input if url not filled', () => { @@ -141,7 +141,7 @@ describe('PopupAddLink', () => { $(okButton).trigger('click'); expect(handler).not.toHaveBeenCalled(); - expect(linkTextInput.classList.contains('wrong')).toBe(true); + expect($(linkTextInput).hasClass('wrong')).toBe(true); }); });