Skip to content

JSX removing leading whitespace in front of charCode #11541

@MarosPistej

Description

@MarosPistej

Describe the bug

About

PR #11474 introduced changes which are causing leading/trailing whitespaces to be trimmed. I believe that issue is in implementation of fn extract_line_content and exact issue i am encountering caused by invocation on line https://github.com/swc-project/swc/pull/11474/changes#diff-8abacd70370fd7f85bb3452458bd542918f7b0a9dc6074dce36d726593c4efe0R1867

Input code

just `white space` in front of `charCode` in JSX:

<span> &#8226; </span>

Config

Link to the code that reproduces this issue

https://play.swc.rs/?version=1.15.11&code=H4sIAAAAAAAAA7MpLkjMs1NQU7YwMjKzVrDRB%2FMBMzIGHBYAAAA%3D&config=H4sIAAAAAAAAA1WPSQ7CMAxF9z1F5DVbWHCHHsIKbpUqk%2BJUIqp6d9JMwM7%2Bg598TELAxhKe4shjXjwGpjD2rHCyEd9ZAZIGWQblI9y6u%2FFlxbBTUc5qQMSwUiwlvrc0aOeYsragZmqaUVYt6ZcnnfGBmP%2BDVxTtqke%2F4qaGBONeezHbHzF5qvgHfEMdNg6D4rk3yxPnB%2BvJL0oTAQAA

SWC Info output

No response

Expected behavior

I expect behavior like in previous version or in babel, preserved leading and trailing space:

Input: <span> &#8226; </span>
Output: React.createElement("span", null, " • ");

Actual behavior

Current behaviour is that leading space is trimmed:

Input: <span> &#8226; </span>
Output: React.createElement("span", null, "• ");

Version

v1.15.11

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions