-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(react): make children
undefined
with experimentalReactChildren
(
#9141) * add test script * make children `undefined` with self-closing tags * add changeset * refactor: simplify
- Loading branch information
Showing
5 changed files
with
33 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@astrojs/react': patch | ||
--- | ||
|
||
Fixes an issue where slotting self-closing elements (img, br, hr) into react components with `experimentalReactChildren` enabled led to an error. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
packages/integrations/react/test/parsed-react-children.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { expect } from 'chai'; | ||
import convert from "../vnode-children.js"; | ||
|
||
describe('experimental react children', () => { | ||
it('has undefined as children for direct children', () => { | ||
const [ imgVNode ] = convert('<img src="abc"></img>'); | ||
expect(imgVNode.props).to.deep.include({ children: undefined }); | ||
}) | ||
|
||
it('has undefined as children for nested children', () => { | ||
const [ divVNode ] = convert('<div><img src="xyz"></img></div>'); | ||
const [ imgVNode ] = divVNode.props.children; | ||
expect(imgVNode.props).to.deep.include({ children: undefined }); | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.