-
Notifications
You must be signed in to change notification settings - Fork 401
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(ssr): non-empty text nodes adjacent with comments #4965
Conversation
(!cxt.prevSibling || | ||
(cxt.prevSibling.type !== 'Text' && | ||
(cxt.templateOptions.preserveComments || cxt.prevSibling.type !== 'Comment'))) && | ||
(!cxt.nextSibling || | ||
(cxt.nextSibling.type !== 'Text' && | ||
(cxt.templateOptions.preserveComments || cxt.nextSibling.type !== 'Comment'))) |
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.
This is a lot of nesting, can we extract it to a function?
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.
Beat me to it :) . I'll do that.
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 appreciate what you're doing here, but this whole "is isolated text node" logic (which predates this PR) is kind of wrong. 🙂 What we need to do instead is:
- Find all adjacent text nodes (and comment nodes, if not running in
lwc:preserve-comments
mode) - Generate code to concatenate them together at runtime (including literals and expressions!)
- If the result is the empty string, then generate the ZWJ character instead
This would be required if we want to fix all the test failures. 🙂
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.
@nolanlawson sounds good. So you're saying it's better to figure out that solution than to push this one first?
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.
No no, it's fine; this is progress. :) BTW we were tackling the same thing today: #4963
packages/@lwc/ssr-compiler/src/compile-template/transformers/text.ts
Outdated
Show resolved
Hide resolved
/nucleus test |
Details
Fixes 5 expected failures:
Does this pull request introduce a breaking change?
Does this pull request introduce an observable change?
GUS work item