Repository navigation
Discard empty TextNode that can creep into appendJSON - #3695
Merged
Merged
Conversation
abelsj60
requested review from
acywatson,
fantactuka,
thegreatercurve,
trueadm,
tylerjbainbridge and
zurfyx
as code owners
January 9, 2023 21:04
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
trueadm
reviewed
Jan 9, 2023
trueadm
reviewed
Jan 10, 2023
trueadm
approved these changes
Jan 13, 2023
This was referenced Jan 24, 2023
Merged
Merged
This was referenced Feb 6, 2023
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If an uncollapsed selection ends or starts at the end of a line of specialized TextNodes, such as code tokens, we will get a 'blank' TextNode in
$appendNodesToJSON. In other words, we'll get a TextNode with a text length of 0 ('').We do not want empty TextNodes, per @trueadm. He calls it an anti-pattern.
So, this PR filters the occasional empty TextNode out of JSON, should it appear.
I am not filtering it out of the sibling function,
$appendNodesToDOM, however, as this can be handled via the exportDOM method instead. It is a more flexible method than exportJSON, so can be leveraged a little more surgically.Filtering could be added to the
$appendNodesToDOMmethod, however, it might be a little more involved. You might have to add a line break (a br?). I was very ginger about function, as I didn't want to break half the planet by accident.I encountered this problem while building a LinedCodeNode. This PR is 2/2 that will let it work without patches.
-j