Skip to content

Commit 08cfe9c

Browse files
committed
Fix to not pass node to basic components
1 parent 96570ff commit 08cfe9c

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,11 @@ function one(state, node, key) {
354354
type = state.components[key]
355355

356356
// If this is swapped out for a component:
357-
if (type !== 'string' && state.passNode) {
357+
if (
358+
typeof type !== 'string' &&
359+
type !== state.Fragment &&
360+
state.passNode
361+
) {
358362
props.node = node
359363
}
360364
} else {

test/index.js

+13
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,19 @@ test('components', async function (t) {
556556
'a'
557557
)
558558
})
559+
560+
await t.test('should not pas `node` to basic components', async function () {
561+
assert.equal(
562+
renderToStaticMarkup(
563+
toJsxRuntime(h('h1', 'a'), {
564+
...production,
565+
passNode: true,
566+
components: {h1: 'h2'}
567+
})
568+
),
569+
'<h2>a</h2>'
570+
)
571+
})
559572
})
560573

561574
test('react specific: filter whitespace in tables', async function (t) {

0 commit comments

Comments
 (0)