Skip to content

Commit 5111a56

Browse files
fix: correctly render wrapped components
The render function no correctly renders the component if the wrapper option is set. Before this it was rendering <innerElement /> to the DOM.
1 parent 6cf1673 commit 5111a56

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ Please checkout the [the open issues][issues]
4343
Also, please watch the repo and respond to questions/bug reports/feature requests! Thanks!
4444
4545
[egghead]: https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github
46-
[issues]: https://github.com/mihar-22/preact-testing-library/issues
46+
[issues]: https://github.com/testing-library/preact-testing-library/issues

src/__tests__/render.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ test('renders options.wrapper around node', () => {
8989
<div
9090
data-testid="wrapper"
9191
>
92-
<innerelement />
92+
<div
93+
data-testid="inner"
94+
/>
9395
</div>
9496
`);
9597
});

src/pure.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ function render(
2929
// they're passing us a custom container or not.
3030
mountedContainers.add(container);
3131

32-
const wrapUiIfNeeded = (innerElement) => (WrapperComponent ? (
33-
<WrapperComponent>
34-
<innerElement/>
35-
</WrapperComponent>
36-
) : innerElement);
32+
const wrapUiIfNeeded = (innerElement) => (WrapperComponent
33+
? h(WrapperComponent, null, innerElement)
34+
: innerElement);
3735

3836
preactAct(() => {
3937
if (hydrate) {

0 commit comments

Comments
 (0)