Skip to content

Commit

Permalink
fix(main): fixed an invalid error in rare conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelParke committed Sep 5, 2016
1 parent e154596 commit 8772907
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,10 @@ textAngular.directive("textAngular", [
/* istanbul ignore next: don't see how to test this... */
if (taSelection.getSelection) {
var _selection = taSelection.getSelection();
if (taSelection.getSelectionElement().nodeName.toLowerCase() === 'a') {
// in a weird case (can't reproduce) taSelection.getSelectionElement() can be undefined!!
// this comes from range.commonAncestorContainer;
// so I check for this here which fixes the error case
if (taSelection.getSelectionElement() && taSelection.getSelectionElement().nodeName.toLowerCase() === 'a') {
// check and see if we are at the edge of the <a>
if (_selection.start.element.nodeType === 3 &&
_selection.start.element.textContent.length === _selection.end.offset) {
Expand Down

0 comments on commit 8772907

Please sign in to comment.