Skip to content

Commit

Permalink
fix selection bug for IE
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Nov 21, 2014
1 parent 779d67a commit e62daef
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/pen.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@

addListener(ctx, editor, 'blur', function() {
checkPlaceholder(ctx);
ctx.checkContentChange();
});

// listen for paste and clear style
Expand Down Expand Up @@ -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;
};

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e62daef

Please sign in to comment.