Skip to content

fix: handle falsy values for #text/#cdata-section/#comment nodes in toXml#2383

Merged
DymoneLewis merged 2 commits into
feature/BPMNAdapter-special-transform-2.2from
copilot/sub-pr-2381
Mar 3, 2026
Merged

fix: handle falsy values for #text/#cdata-section/#comment nodes in toXml#2383
DymoneLewis merged 2 commits into
feature/BPMNAdapter-special-transform-2.2from
copilot/sub-pr-2381

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 3, 2026

The falsy short-circuit in toXml fired before the #text/#cdata-section/#comment branch checks, causing nodes like { '#text': '' } to emit <#text /> — invalid XML — instead of correct empty text content.

Changes

  • bpmn-elements-adapter/json2xml.ts: Reordered branches in toXml so #text, #cdata-section, and #comment are evaluated before the falsy self-closing guard. The guard now only applies to regular element names.
// Before: empty #text emits invalid <#text />
if (obj !== 0 && obj !== false && !obj) return `${prefix}<${name} />`  // ← fires first
if (name === '#text') return prefix + escapeXml(String(obj))

// After: special names handled first
if (name === '#text') return prefix + escapeXml(String(obj))           // ← correct
if (obj !== 0 && obj !== false && !obj) return `${prefix}<${name} />`

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 3, 2026

⚠️ No Changeset found

Latest commit: a363de5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Co-authored-by: DymoneLewis <35758043+DymoneLewis@users.noreply.github.com>
Copilot AI changed the title [WIP] Update BPMNAdapter special string escaping implementation fix: handle falsy values for #text/#cdata-section/#comment nodes in toXml Mar 3, 2026
@DymoneLewis DymoneLewis marked this pull request as ready for review March 3, 2026 09:11
@DymoneLewis DymoneLewis merged commit 071aa95 into feature/BPMNAdapter-special-transform-2.2 Mar 3, 2026
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.

2 participants