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(compiler-core): keep whitespaces with newline between interpolation and comment #6828

Merged
merged 1 commit into from Nov 8, 2022

Conversation

rudyxu1102
Copy link
Contributor

@rudyxu1102 rudyxu1102 commented Oct 6, 2022

@rudyxu1102 rudyxu1102 marked this pull request as draft October 6, 2022 12:29
@rudyxu1102 rudyxu1102 marked this pull request as ready for review October 6, 2022 12:53
Copy link
Member

@znck znck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can shorten the condition to:
(prev.type === ELEMENT || prev.type === COMMENT) && (next.type === ELEMENT || next.type === COMMENT)

@rudyxu1102
Copy link
Contributor Author

@znck But the test case below will be failed. The whitespaces without newline between elements shouldn't remove.

it('should NOT remove whitespaces w/o newline between elements', () => {
      const ast = parse(`<div/> <div/> <div/>`)
      expect(ast.children.length).toBe(5)
      expect(ast.children.map(c => c.type)).toMatchObject([
        NodeTypes.ELEMENT,
        NodeTypes.TEXT,
        NodeTypes.ELEMENT,
        NodeTypes.TEXT,
        NodeTypes.ELEMENT
      ])
    })

@rudyxu1102 rudyxu1102 changed the title fix(compiler-core): keep whitespaces between interpolation and comment fix(compiler-core): keep whitespaces with newline between interpolation and comment Oct 7, 2022
@antfu antfu requested a review from znck October 10, 2022 04:36
@znck znck added the 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. label Oct 11, 2022
@yyx990803 yyx990803 merged commit 4887618 into vuejs:main Nov 8, 2022
@rudyxu1102 rudyxu1102 deleted the fix/6352 branch November 9, 2022 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Whitespace is removed when a comment appears between a tag and an interpolation
3 participants