Skip to content

Normalize createTextNode hook data - #690

Open
olavoasantos wants to merge 1 commit into
default-custom-event-detailfrom
normalize-text-node-hooks
Open

olavoasantos wants to merge 1 commit into
default-custom-event-detailfrom
normalize-text-node-hooks

Conversation

@olavoasantos

@olavoasantos olavoasantos commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Problem

Document.createTextNode() normalized nullish input in the Text node constructor, but passed String(data) to the createText hook. As a result, the local node and the Remote DOM hook described different text for the same operation.

Impact

Minor. Creating a text node with null or undefined stored '' locally while emitting 'null' or 'undefined' to the hook. A remote receiver could therefore render text that did not exist in the worker’s local DOM.

Reproduction

window[HOOKS].createText = (_text, data) => console.log(data);

const text = document.createTextNode(null);

text.data; // ''

Before this change, the hook logged 'null' even though text.data was ''; undefined had the equivalent mismatch. It now receives text.data, so both values are ''. Empty and ordinary strings continue to reach the hook unchanged.

Change

Pass the newly created node’s normalized data property to createText rather than independently coercing the original argument. This makes the hook payload use the same single normalization result as local CharacterData.

Tests

Adds focused hook assertions for null, undefined, '', and an ordinary string. Each test verifies the stored text data, the node passed to the hook, and the hook payload agree.

Stack

Validation

Fresh GitHub CI on restacked head e1acf97 passes:

  • lint;
  • type-check and build;
  • unit tests with coverage;
  • bundle-size checks;
  • Playwright end-to-end tests;
  • the classified Web Platform Test suite.

@olavoasantos
olavoasantos force-pushed the normalize-text-node-hooks branch from 5863b4e to 291e2de Compare September 3, 2026 15:30
@olavoasantos
olavoasantos force-pushed the normalize-text-node-hooks branch from 291e2de to e1acf97 Compare September 4, 2026 14:31
@olavoasantos
olavoasantos marked this pull request as ready for review September 4, 2026 15:29
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.

4 participants