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

domRange.setStart being called with offset of 1 on a zero length text node #5760

Open
bmingles opened this issue Nov 2, 2024 · 0 comments
Open

Comments

@bmingles
Copy link
Contributor

bmingles commented Nov 2, 2024

Description
On IOS, toDOMRange can call domRange.setStart with an invalid offset. This is caused by a conditional rendering of '\uFEFF' that gets excluded on IOS.

{!(IS_ANDROID || IS_IOS) || !isLineBreak ? '\uFEFF' : null}

A later call to toDOMRange can fail due to passing 1 as the offset to a textnode that has a zero length string.

domRange.setStart(startNode, isStartAtZeroWidth ? 1 : startOffset)

image image

Expectation
toDOMRange should check for conditions that don't render the \uFEFF character and pass 0 instead of 1 to domRange.setStart in such cases.

Note that this is happening in a new SolidJS based package, so I don't have reproduction steps in slate-react, but the DOM looks like this:

image

Environment

  • Slate Version: 111
  • Operating System: MacOS
  • Browser: Chrome (emulating iOS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant