gorhill / gorhill/efatmarker

In Chromium, range.endContainer can be a non-text node type

Open
#1 0 comments 0 reactions 1 assignee Claimed by @gorhill View on GitHub
bug
Dominant language
JavaScript
Stars
40
Forks
1
PR merge metrics
No merged PRs in 30d

Description

In Chromium, range.endContainer can be a non-text type of node, which then cause EFatMarker.normalizeOffset() to fail and return -1 as the normalized offset. Result: what should be a valid selection is not highlighted.

At first glance, solution seems to be that whenever a non-text type of node is encountered for range.endContainer, to walk backward in the DOM hierarchy until a text node is found (aka finding the nearest preceding text node), at which point this text node would replace range.endContainer, and the text length of this text node would replace range.endOffset.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.