Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

div:contenteditable update range for everytime focus event is triggered #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

g-viet
Copy link

@g-viet g-viet commented May 25, 2018

ref needim#45

@tje3d It does not work in Safari.
In Safari, I guess when focus event is triggered, window.getSelection() take no range, window.r angeCount = 0, then it can not update range.

el.addEventListener('focus', function () {
      var s = window.getSelection();
      if (!wdtEmojiBundle.ranges[this.dataset.rangeIndex]) {
        wdtEmojiBundle.ranges[this.dataset.rangeIndex] = new Range();
      } else if (s.rangeCount > 0) {
        s.removeAllRanges();
        s.addRange(wdtEmojiBundle.ranges[this.dataset.rangeIndex]);
      }
    });

So I removed if (s.rangeCount > 0)

@tje3d
Copy link
Owner

tje3d commented May 26, 2018

Oh, will take a look into soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants