Skip to content

fix: use self-closing tags when children are implictly hidden#299

Merged
Joannis merged 1 commit into
CoreOffice:mainfrom
JoshBashed:fix/self-closing-empty-case
May 13, 2026
Merged

fix: use self-closing tags when children are implictly hidden#299
Joannis merged 1 commit into
CoreOffice:mainfrom
JoshBashed:fix/self-closing-empty-case

Conversation

@JoshBashed
Copy link
Copy Markdown
Contributor

Closes #298

Important

Although the issue was generated using AI tools, the PR's code was written by a human.

When a choice case uses _0 = "" to inline an associated value whose contents are XML attributes only, the encoder was emitting an empty open/close pair (<Tag Attr="..."></Tag>) instead of a self-closing tag (<Tag Attr="..." />).

The attributes correctly bubbled up to the parent via formatXMLAttributes, but the empty-keyed phantom child stayed in the elements list, so !elements.isEmpty forced the encoder onto the open/close path.

Changes

  • Add isPracticallyEmpty to recursively check if a tag can be self-closing.

Important

formatXMLAttributes doesn't recognize tags with no elements inside children and this PR doesn't change that behavior.

  • Use isPracticallyEmpty when deciding whether to self-close an element.
  • Add a test case in InlinePropertyTests to ensure the behavior remains.
  • Fix existing test cases.

@Joannis Joannis merged commit 42f6238 into CoreOffice:main May 13, 2026
3 of 8 checks passed
@JoshBashed JoshBashed deleted the fix/self-closing-empty-case branch May 13, 2026 07:39
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.

Self-closing tags broken for choice enums with _0 = "" inlining when inner type is attribute-only

2 participants