Skip to content

Fix nullish default props#4775

Merged
JoviDeCroock merged 1 commit intomainfrom
fix-nullish-default-props
May 27, 2025
Merged

Fix nullish default props#4775
JoviDeCroock merged 1 commit intomainfrom
fix-nullish-default-props

Conversation

@JoviDeCroock
Copy link
Copy Markdown
Member

Fixes #4774

This PR fixes an issue with the handling of null values in component props when default props are set. Previously, the loose equality check (==) would treat null values the same as undefined, causing default props to override explicitly passed null values. The fix changes these checks to strict equality (===), ensuring that null values are preserved as intended.

The change applies to:

  • createElement
  • cloneElement
  • jsx-runtime

Test cases were added to verify proper handling of null prop values with defaultProps in all affected locations.

@JoviDeCroock JoviDeCroock requested a review from rschristian May 27, 2025 16:52
@github-actions
Copy link
Copy Markdown

github-actions bot commented May 27, 2025

📊 Tachometer Benchmark Results

Summary

duration

  • create10k: unsure 🔍 -0% - +0% (-4.52ms - +1.70ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -1% - +4% (-0.13ms - +0.59ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -2% - +1% (-1.76ms - +0.49ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -3% - +1% (-0.55ms - +0.10ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -2% - +2% (-1.15ms - +0.99ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -5% - +5% (-0.09ms - +0.10ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -1% - +1% (-0.23ms - +0.44ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -3% - +2% (-0.99ms - +0.79ms)
    preact-local vs preact-main

usedJSHeapSize

  • create10k: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -4% - +4% (-0.31ms - +0.27ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -3% - +2% (-0.04ms - +0.02ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -1% - +1% (-0.01ms - +0.02ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main

Results

create10k

duration

VersionAvg timevs preact-localvs preact-main
preact-local989.01ms - 993.04ms-unsure 🔍
-0% - +0%
-4.52ms - +1.70ms
preact-main990.06ms - 994.80msunsure 🔍
-0% - +0%
-1.70ms - +4.52ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local19.18ms - 19.18ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main19.18ms - 19.18msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
filter-list

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.45ms - 17.15ms-unsure 🔍
-1% - +4%
-0.13ms - +0.59ms
preact-main16.49ms - 16.65msunsure 🔍
-3% - +1%
-0.59ms - +0.13ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.54ms - 1.54ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main1.54ms - 1.54msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
hydrate1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local78.36ms - 79.89ms-unsure 🔍
-2% - +1%
-1.76ms - +0.49ms
preact-main78.93ms - 80.59msunsure 🔍
-1% - +2%
-0.49ms - +1.76ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local7.18ms - 7.59ms-unsure 🔍
-4% - +4%
-0.31ms - +0.27ms
preact-main7.20ms - 7.61msunsure 🔍
-4% - +4%
-0.27ms - +0.31ms
-
many-updates

duration

VersionAvg timevs preact-localvs preact-main
preact-local15.83ms - 16.21ms-unsure 🔍
-3% - +1%
-0.55ms - +0.10ms
preact-main15.98ms - 16.51msunsure 🔍
-1% - +3%
-0.10ms - +0.55ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.77ms - 3.78ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main3.77ms - 3.78msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
replace1k
  • Browser: chrome-headless
  • Sample size: 100
  • Built by: CI #4713
  • Commit: cd75f0a

duration

VersionAvg timevs preact-localvs preact-main
preact-local62.77ms - 64.25ms-unsure 🔍
-2% - +2%
-1.15ms - +0.99ms
preact-main62.81ms - 64.37msunsure 🔍
-2% - +2%
-0.99ms - +1.15ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local2.98ms - 2.99ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main2.98ms - 2.98msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-

run-warmup-0

VersionAvg timevs preact-localvs preact-main
preact-local26.10ms - 26.76ms-unsure 🔍
-1% - +3%
-0.21ms - +0.74ms
preact-main25.83ms - 26.50msunsure 🔍
-3% - +1%
-0.74ms - +0.21ms
-

run-warmup-1

VersionAvg timevs preact-localvs preact-main
preact-local33.36ms - 34.66ms-unsure 🔍
-3% - +2%
-1.17ms - +0.75ms
preact-main33.52ms - 34.92msunsure 🔍
-2% - +3%
-0.75ms - +1.17ms
-

run-warmup-2

VersionAvg timevs preact-localvs preact-main
preact-local29.47ms - 30.49ms-unsure 🔍
-1% - +4%
-0.17ms - +1.23ms
preact-main28.97ms - 29.93msunsure 🔍
-4% - +1%
-1.23ms - +0.17ms
-

run-warmup-3

VersionAvg timevs preact-localvs preact-main
preact-local26.98ms - 27.93ms-unsure 🔍
-3% - +2%
-0.86ms - +0.44ms
preact-main27.23ms - 28.11msunsure 🔍
-2% - +3%
-0.44ms - +0.86ms
-

run-warmup-4

VersionAvg timevs preact-localvs preact-main
preact-local23.66ms - 24.70ms-unsure 🔍
-2% - +5%
-0.37ms - +1.16ms
preact-main23.23ms - 24.34msunsure 🔍
-5% - +1%
-1.16ms - +0.37ms
-

run-final

VersionAvg timevs preact-localvs preact-main
preact-local21.20ms - 22.03ms-unsure 🔍
-2% - +4%
-0.33ms - +0.81ms
preact-main20.98ms - 21.76msunsure 🔍
-4% - +2%
-0.81ms - +0.33ms
-
text-update

duration

VersionAvg timevs preact-localvs preact-main
preact-local2.02ms - 2.16ms-unsure 🔍
-5% - +5%
-0.09ms - +0.10ms
preact-main2.02ms - 2.16msunsure 🔍
-5% - +5%
-0.10ms - +0.09ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.13ms - 1.17ms-unsure 🔍
-3% - +2%
-0.04ms - +0.02ms
preact-main1.13ms - 1.18msunsure 🔍
-2% - +3%
-0.02ms - +0.04ms
-
todo

duration

VersionAvg timevs preact-localvs preact-main
preact-local33.57ms - 34.16ms-unsure 🔍
-1% - +1%
-0.23ms - +0.44ms
preact-main33.59ms - 33.92msunsure 🔍
-1% - +1%
-0.44ms - +0.23ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.24ms - 1.26ms-unsure 🔍
-1% - +1%
-0.01ms - +0.02ms
preact-main1.24ms - 1.25msunsure 🔍
-1% - +1%
-0.02ms - +0.01ms
-
update10th1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local32.07ms - 33.34ms-unsure 🔍
-3% - +2%
-0.99ms - +0.79ms
preact-main32.18ms - 33.43msunsure 🔍
-2% - +3%
-0.79ms - +0.99ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local2.94ms - 2.95ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main2.94ms - 2.95msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-

tachometer-reporter-action v2 for CI

@github-actions
Copy link
Copy Markdown

Size Change: +16 B (+0.02%)

Total Size: 78.7 kB

Filename Size Change
dist/preact.js 4.75 kB +3 B (+0.06%)
dist/preact.min.js 4.77 kB +1 B (+0.02%)
dist/preact.min.module.js 4.78 kB +4 B (+0.08%)
dist/preact.min.umd.js 4.8 kB +1 B (+0.02%)
dist/preact.mjs 4.76 kB +3 B (+0.06%)
dist/preact.module.js 4.76 kB +3 B (+0.06%)
dist/preact.umd.js 4.8 kB +1 B (+0.02%)
ℹ️ View Unchanged
Filename Size
compat/dist/compat.js 4.15 kB
compat/dist/compat.mjs 4.08 kB
compat/dist/compat.module.js 4.08 kB
compat/dist/compat.umd.js 4.21 kB
debug/dist/debug.js 3.82 kB
debug/dist/debug.mjs 3.82 kB
debug/dist/debug.module.js 3.82 kB
debug/dist/debug.umd.js 3.9 kB
devtools/dist/devtools.js 260 B
devtools/dist/devtools.mjs 274 B
devtools/dist/devtools.module.js 274 B
devtools/dist/devtools.umd.js 346 B
hooks/dist/hooks.js 1.54 kB
hooks/dist/hooks.mjs 1.57 kB
hooks/dist/hooks.module.js 1.57 kB
hooks/dist/hooks.umd.js 1.61 kB
jsx-runtime/dist/jsxRuntime.js 978 B
jsx-runtime/dist/jsxRuntime.mjs 952 B
jsx-runtime/dist/jsxRuntime.module.js 952 B
jsx-runtime/dist/jsxRuntime.umd.js 1.05 kB
test-utils/dist/testUtils.js 473 B
test-utils/dist/testUtils.mjs 477 B
test-utils/dist/testUtils.module.js 477 B
test-utils/dist/testUtils.umd.js 555 B

compressed-size-action

@JoviDeCroock JoviDeCroock merged commit c4dc71e into main May 27, 2025
12 checks passed
@JoviDeCroock JoviDeCroock deleted the fix-nullish-default-props branch May 27, 2025 17:29
@JoviDeCroock JoviDeCroock mentioned this pull request May 28, 2025
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.

defaultProps incorrectly applied when passing null

2 participants