From e62daef500d759113e6177a0bc69c31588f7dc80 Mon Sep 17 00:00:00 2001 From: zensh Date: Fri, 21 Nov 2014 11:46:49 +0800 Subject: [PATCH] fix selection bug for IE --- src/pen.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/pen.js b/src/pen.js index d1de877..dd4735d 100644 --- a/src/pen.js +++ b/src/pen.js @@ -273,6 +273,7 @@ addListener(ctx, editor, 'blur', function() { checkPlaceholder(ctx); + ctx.checkContentChange(); }); // listen for paste and clear style @@ -507,8 +508,10 @@ range = this.getRange(); range.collapse(false); // set to end } - selection.removeAllRanges(); - selection.addRange(range); + try { + selection.removeAllRanges(); + selection.addRange(range); + } catch (e) {/* IE throws error sometimes*/} return this; }; @@ -696,8 +699,10 @@ if (!isAJoke) { removeAllListeners(this); - selection.removeAllRanges(); - this._menu.parentNode.removeChild(this._menu); + try { + selection.removeAllRanges(); + this._menu.parentNode.removeChild(this._menu); + } catch (e) {/* IE throws error sometimes*/} } else { initToolbar(this); initEvents(this);