From 59797975a3ccf2bee825809f67e05ca4a28e2647 Mon Sep 17 00:00:00 2001 From: Jake Archibald Date: Tue, 3 Sep 2024 14:18:25 +0100 Subject: [PATCH] Call hook when creating text (#436) * Call hook when creating text * CHangeset --- .changeset/mean-snakes-shave.md | 5 +++++ packages/polyfill/source/Document.ts | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/mean-snakes-shave.md diff --git a/.changeset/mean-snakes-shave.md b/.changeset/mean-snakes-shave.md new file mode 100644 index 00000000..1c69a384 --- /dev/null +++ b/.changeset/mean-snakes-shave.md @@ -0,0 +1,5 @@ +--- +'@remote-dom/polyfill': patch +--- + +Ensure the `createText` hook is called when creating a new text node diff --git a/packages/polyfill/source/Document.ts b/packages/polyfill/source/Document.ts index 4c67374c..44285ad7 100644 --- a/packages/polyfill/source/Document.ts +++ b/packages/polyfill/source/Document.ts @@ -50,7 +50,9 @@ export class Document extends ParentNode { } createTextNode(data: any) { - return createNode(new Text(data), this); + const text = createNode(new Text(data), this); + this[HOOKS].createText?.(text as any, String(data)); + return text; } createComment(data: any) {