Skip to content

fix(compiler-core): preserve whitespace around interpolations (fix #7542) - #15168

Draft
fengnovo wants to merge 1 commit into
vuejs:mainfrom
fengnovo:fix/interpolation-boundary-whitespace
Draft

fix(compiler-core): preserve whitespace around interpolations (fix #7542)#15168
fengnovo wants to merge 1 commit into
vuejs:mainfrom
fengnovo:fix/interpolation-boundary-whitespace

Conversation

@fengnovo

Copy link
Copy Markdown

Summary

Preserve condensed boundary whitespace when an interpolation is the first or last child of a non-root element.

This makes interpolated content consistent with static text in inline markup. For example:

<span>Foo</span>
<span>
  {{ bar }}
</span>

now renders with the source whitespace between Foo and the interpolated value instead of collapsing the output to FooBar.

Root cause

condenseWhitespace() unconditionally removed all-whitespace text nodes at the start and end of every child list. That also removed whitespace adjacent to an interpolation, even though equivalent static text preserves a condensed space.

The parser now distinguishes root-level whitespace from element boundary whitespace. In the default condense mode, it keeps a single boundary space next to an interpolation inside an element. Root-level behavior and whitespace: 'preserve' behavior remain unchanged.

Tests

  • Added parser coverage for leading and trailing whitespace around interpolations.
  • Added guards for root-level whitespace and whitespace: 'preserve'.
  • Updated compiler and runtime expectations affected by the corrected output.
  • ./node_modules/.bin/vitest --project 'unit*' run
    • 182 test files passed, 1 skipped
    • 3629 tests passed, 6 skipped
  • ./node_modules/.bin/tsc --incremental --noEmit

Fixes #7542

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9d916d7f-7792-4b3d-a3fd-76b97321338d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

inconsistent behaviour of whitespace: 'condense' handling if second element text is an interpolated var

1 participant