-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix splitText when detached #6501
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a net improvement, but I think there may be other edge cases left in this method
if (hasReplacedSelf) { | ||
writableParent.splice(insertionIndex, 0, splitNodes); | ||
this.remove(); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this isn't the code that's changing in this PR but it seems like there might be a hasReplacedSelf selection bug, the above code to fixup selections only handles parts>0 and the splice selection fixup code won't do anything either because the node removal is happening separately. It also seems a bit odd that the special case only happens with IS_SEGMENTED and not IS_TOKEN
When
splitText
is run on a Node with no parent it crashes. I don't see any obvious reason why this function should only work on attached nodes and there are some valid cases when you'd want to attach the resulting nodes later and leveragesplitText
to preserve the styling and format.