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

fix(ssr): non-empty text nodes adjacent with comments #4965

Merged
merged 2 commits into from
Nov 26, 2024

Conversation

cardoso
Copy link
Contributor

@cardoso cardoso commented Nov 26, 2024

Details

Fixes 5 expected failures:

    'adjacent-text-nodes/with-comments/nonempty1/index.js',
    'adjacent-text-nodes/with-comments/nonempty2/index.js',
    'adjacent-text-nodes/with-comments/nonempty3/index.js',
    'comments-text-preserve-off/index.js',
    'empty-text-with-comments-non-static-optimized/index.js',

Does this pull request introduce a breaking change?

  • 😮‍💨 No, it does not introduce a breaking change.

Does this pull request introduce an observable change?

  • 🤞 No, it does not introduce an observable change.

GUS work item

@cardoso cardoso requested a review from a team as a code owner November 26, 2024 21:47
Comment on lines 48 to 53
(!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')))
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

@nolanlawson nolanlawson Nov 26, 2024

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:

  1. Find all adjacent text nodes (and comment nodes, if not running in lwc:preserve-comments mode)
  2. Generate code to concatenate them together at runtime (including literals and expressions!)
  3. 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. 🙂

Copy link
Contributor Author

@cardoso cardoso Nov 26, 2024

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?

Copy link
Collaborator

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

@nolanlawson
Copy link
Collaborator

/nucleus test

@nolanlawson nolanlawson merged commit c3db1c7 into salesforce:master Nov 26, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants