Skip to content

Commit 75e7dec

Browse files
committed
remove vnode casting
1 parent b7f1d8b commit 75e7dec

File tree

4 files changed

+15
-19
lines changed

4 files changed

+15
-19
lines changed

.changeset/quiet-toes-carry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'preact-render-to-string': major
3+
---
4+
5+
Remove the castin to VNode for `preact/debug`, this is fixed in Preact >= 10.13.0

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
"lint-staged": "^10.5.3",
122122
"microbundle": "^0.15.1",
123123
"mocha": "^8.2.1",
124-
"preact": "^10.11.1",
124+
"preact": "^10.13.0",
125125
"prettier": "^2.2.1",
126126
"sinon": "^9.2.2",
127127
"sinon-chai": "^3.5.0",

src/index.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const assign = Object.assign;
2222

2323
// Global state for the current render pass
2424
let beforeDiff, afterDiff, renderHook, ummountHook;
25+
const parent = h(Fragment, null);
2526

2627
/**
2728
* Render Preact JSX + Components to an HTML string.
@@ -44,7 +45,6 @@ export default function renderToString(vnode, context) {
4445
renderHook = options[RENDER];
4546
ummountHook = options.unmount;
4647

47-
const parent = h(Fragment, null);
4848
parent[CHILDREN] = [vnode];
4949

5050
try {
@@ -145,15 +145,6 @@ function _renderToString(vnode, context, isSvgMode, selectValue, parent) {
145145
rendered =
146146
rendered +
147147
_renderToString(child, context, isSvgMode, selectValue, parent);
148-
149-
if (
150-
typeof child === 'string' ||
151-
typeof child === 'number' ||
152-
typeof child === 'bigint'
153-
) {
154-
// @ts-ignore manually constructing a Text vnode
155-
vnode[i] = h(null, null, child);
156-
}
157148
}
158149
return rendered;
159150
}

0 commit comments

Comments
 (0)