Skip to content

Preserve JSX tag syntax in autofmt - #5731

Open
nicoburns wants to merge 1 commit into
devin/1785758131-jsx-syntaxfrom
devin/1785764450-jsx-autofmt
Open

Preserve JSX tag syntax in autofmt#5731
nicoburns wants to merge 1 commit into
devin/1785758131-jsx-syntaxfrom
devin/1785764450-jsx-autofmt

Conversation

@nicoburns

Copy link
Copy Markdown
Member

Summary

Stacked on #5730. Makes dx fmt/autofmt keep rsx written in the JSX/XML tag syntax in that style instead of rewriting it into block syntax.

  • dioxus-rsx: Element and Component gain a tag_syntax: bool field, set by the JSX parser, so downstream consumers know which style the node was written in.
  • dioxus-autofmt: write_element/write_component dispatch to a new write_jsx_tag when tag_syntax is set:
    • self-closing tags for empty children: <img src="image.png" />
    • single short child inlined: <h1>"Hello"</h1>
    • attributes inline in the opening tag when short, otherwise one per line with the closing > on its own line
    • attribute values printed as name="literal" / name={expr}, shorthand collapsing (disabled={disabled}disabled), spreads as {..attrs}, dashed custom attributes unquoted (data-count="1"), and components printed without the turbofish (<Outlet<R>>)

Mixed block/JSX styles are preserved as written, since dispatch happens per node.

Tests: idempotency sample (tests/samples/jsx.rsx) and a normalization test (tests/wrong/jsx-4sp*).

Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/418cbef546c844b6b40c575b1ae28376
Requested by: @nicoburns

@nicoburns nicoburns self-assigned this Aug 3, 2026
@staging-devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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.

1 participant