Skip to content

Compare and hash DOM nodes and ranges by reference in Equal and Hash - #11445

Merged
tim-smart merged 8 commits into
Effect-TS:mainfrom
max-sixty:fix/equal-dom-nodes
Dec 3, 2026
Merged

tim-smart merged 8 commits into
Effect-TS:mainfrom
max-sixty:fix/equal-dom-nodes

Conversation

@max-sixty

@max-sixty max-sixty commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Equal.equals and Hash.hash fell through to structural comparison for DOM nodes and ranges. Walking their properties traverses the document and can throw on platform getters, which affects UI props, shared atoms, and the default equivalence of Schema.instanceOf.

DOM nodes and ranges without their own Equal / Hash implementation now compare by reference and get a stable identity hash (Hash.random). Detection walks the value's prototype chain. A node matches when a prototype owns both DOCUMENT_NODE and nodeType (Node.prototype). A range matches when a prototype's own Symbol.toStringTag data value is AbstractRange (the browser base of Range and StaticRange), or when it owns both compareBoundaryPoints and startOffset (happy-dom's Range.prototype, which has no AbstractRange). Ordinary classes with look-alike members, such as startOffset/endOffset getters, a lone compareBoundaryPoints method or a DOCUMENT_NODE getter, stay on the structural path. Only own property descriptors are read, so no getter runs and globalThis is not consulted. The check only runs on the structural record fallback, so arrays, Maps, Sets, buffers, and Equal / Hash implementers are unaffected. It adds 131 B gzip to the Effect-only UI client.

Validation: pnpm test --run packages/effect/test/Equal.test.ts packages/effect/test/Hash.test.ts, pnpm lint-fix, pnpm check, pnpm jsdocs --check, pnpm bundle-size-ui, and a headless Chromium run covering look-alike classes, StaticRange, cross-realm and detached nodes and ranges.

Closes EFF-5218

@changeset-bot

changeset-bot Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d56c6ee

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

This PR includes changesets to release 43 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/vitest Patch
@effect/ai-amazon-bedrock Patch
@effect/ai-anthropic Patch
@effect/ai-cloudflare Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/ai-typesafe Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/chat-discord Patch
@effect/chat-slack Patch
@effect/chat-teams Patch
@effect/chat-telegram Patch
@effect/chat-whatsapp Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-cloudflare Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/graphql-generator Patch
@effect/openapi-generator Patch
@effect/ui-devtools Patch
@effect/ui-native Patch
@effect/ui-opentui 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

@effect-janitor effect-janitor Bot added the 4.0 label Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 40.55 KB 40.45 KB +0.11 KB (+0.26%)
basic.ts 6.80 KB 6.66 KB +0.14 KB (+2.09%)
batching.ts 12.03 KB 11.90 KB +0.13 KB (+1.05%)
brand.ts 7.03 KB 6.91 KB +0.13 KB (+1.81%)
cache.ts 12.30 KB 12.16 KB +0.14 KB (+1.13%)
config.ts 24.02 KB 23.89 KB +0.13 KB (+0.54%)
differ.ts 22.88 KB 22.75 KB +0.13 KB (+0.57%)
http-client.ts 29.03 KB 28.90 KB +0.13 KB (+0.44%)
http-router.ts 39.70 KB 39.57 KB +0.13 KB (+0.34%)
logger.ts 12.46 KB 12.34 KB +0.12 KB (+0.97%)
metric.ts 10.29 KB 10.16 KB +0.13 KB (+1.24%)
optic.ts 7.26 KB 7.14 KB +0.12 KB (+1.62%)
pubsub.ts 17.02 KB 16.89 KB +0.12 KB (+0.72%)
queue.ts 13.83 KB 13.71 KB +0.12 KB (+0.90%)
schedule.ts 12.59 KB 12.46 KB +0.13 KB (+1.03%)
schema-bigdecimal.ts 14.62 KB 14.50 KB +0.12 KB (+0.85%)
schema-binary.ts 43.61 KB 43.50 KB +0.11 KB (+0.26%)
schema-class.ts 22.61 KB 22.50 KB +0.11 KB (+0.48%)
schema-codegen.ts 33.98 KB 33.86 KB +0.12 KB (+0.35%)
schema-fromJsonSchemaDocument.ts 31.06 KB 30.95 KB +0.10 KB (+0.34%)
schema-representation-roundtrip.ts 28.80 KB 28.69 KB +0.11 KB (+0.39%)
schema-string-transformation.ts 16.39 KB 16.26 KB +0.13 KB (+0.79%)
schema-string.ts 12.89 KB 12.78 KB +0.12 KB (+0.91%)
schema-template-literal.ts 16.99 KB 16.86 KB +0.13 KB (+0.79%)
schema-toArbitrary.ts 40.12 KB 40.00 KB +0.13 KB (+0.32%)
schema-toCodecJson.ts 21.77 KB 21.64 KB +0.13 KB (+0.61%)
schema-toEquivalence.ts 21.93 KB 21.81 KB +0.12 KB (+0.55%)
schema-toFormatter.ts 22.04 KB 21.90 KB +0.13 KB (+0.61%)
schema-toJsonSchemaDocument.ts 27.05 KB 26.94 KB +0.11 KB (+0.42%)
schema-toRepresentation.ts 22.08 KB 21.96 KB +0.11 KB (+0.52%)
schema.ts 21.73 KB 21.61 KB +0.12 KB (+0.56%)
stm.ts 15.08 KB 14.96 KB +0.11 KB (+0.76%)
stream.ts 10.83 KB 10.70 KB +0.13 KB (+1.20%)
supervisor.ts 12.27 KB 12.13 KB +0.13 KB (+1.10%)

UI Bundle Size

Vite 8.4.0/Rolldown, production, default Oxc minification, es2023, ES modules, gzip level 9 per chunk. effect 4.2.0, Node v26.12.1. Effect-only client: 27528 B gzip (Δ +120 B vs base).

App Chunks Raw bytes Gzip bytes Added gzip B Δ raw bytes Δ gzip bytes
counter 1 176280 60862 33334 +361 +113
features 1 185934 64361 36833 +363 +128
menu 1 290721 99073 71545 +355 +144

@tim-smart
tim-smart merged commit 974e748 into Effect-TS:main Dec 3, 2026
22 of 23 checks passed

This branch is waiting to be deployed

1 waiting deployment
fork — d56c6ee0 Waiting Dec 3, 2026 by effect-bot via approval-gate #29442
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants