Skip to content

Commit

Permalink
Merge pull request #121 from teambition/master
Browse files Browse the repository at this point in the history
fix selection bug for IE
  • Loading branch information
sofish committed Nov 21, 2014
2 parents 779d67a + e62daef commit 0d940bc
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 0d940bc

Please sign in to comment.