Skip to content

fix(web): remove falsy sole-child primitives when replacing content - #3573

Merged
ryansolid merged 2 commits into
solidjs:nextfrom
Yahiro025:fix/sole-child-falsy-primitive-3571
Sep 22, 2026
Merged

ryansolid merged 2 commits into
solidjs:nextfrom
Yahiro025:fix/sole-child-falsy-primitive-3571

Conversation

@Yahiro025

Copy link
Copy Markdown

Summary

Fixes #3571 on the Solid 2.0.0-rc.9 line.

insertExpression keeps a sole primitive child as the raw value in current. The node and array replacement paths tested that value by truthiness, so 0 and NaN skipped cleanup. The old text node stayed, new content was appended after it, and zeros accumulated on later toggles.

Those checks now use current != null, so the text node is replaced or removed. Empty string and false still never become current (flatten drops them first).

Test plan

  • New spec: 0 → element → 0 → number (incl. second toggle), NaN, 0 ↔ array, and items().length && <For>
  • Client suite green
  • Hydration suite green
  • Changeset included

Notes

Implementation assisted by AI; reviewed before opening. Authorship Yahiro025-only.

@changeset-bot

changeset-bot Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f71aa9a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@solidjs/web Patch
@solidjs/babel-plugin Patch
@solidjs/element Patch
@solidjs/h Patch
@solidjs/html Patch
test-integration Patch
@solidjs/compiler Patch
@solidjs/diagnostics Patch
@solidjs/signals Patch
solid-js Patch
@solidjs/universal Patch

Not sure what this means? Click here to learn what changesets are.

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

Yahiro025 and others added 2 commits September 22, 2026 01:03
A sole dynamic child of 0 or NaN is tracked as the raw primitive. Truthiness
checks in insertExpression skipped cleanup, so a later element or array was
appended beside the old text node and zeros accumulated on later toggles.
…olidjs#3571)

Array.isArray(current) drops the last truthiness read of current in insertExpression.

Co-authored-by: Claude via Cursor <noreply@cursor.com>
@ryansolid
ryansolid force-pushed the fix/sole-child-falsy-primitive-3571 branch from ddc2c65 to f71aa9a Compare September 22, 2026 09:08
@codspeed

codspeed Bot commented Sep 22, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 172 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing Yahiro025:fix/sole-child-falsy-primitive-3571 (f71aa9a) with next (709c02b)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@ryansolid
ryansolid merged commit 495db9c into solidjs:next Sep 22, 2026
7 checks passed
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