Fix crash when children are undefined (#1885)
* ensure children always exist * update changelog
This commit is contained in:
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
- Call `displayValue` with a v-model of `ref(undefined)` on `ComboboxInput` ([#1865](https://github.com/tailwindlabs/headlessui/pull/1865))
|
||||
- Improve `Portal` detection for `Popover` components ([#1842](https://github.com/tailwindlabs/headlessui/pull/1842))
|
||||
- Fix crash when `children` are `undefined` ([#1885](https://github.com/tailwindlabs/headlessui/pull/1885))
|
||||
|
||||
## [1.7.2] - 2022-09-15
|
||||
|
||||
|
||||
@@ -91,6 +91,12 @@ describe('Safe guards', () => {
|
||||
|
||||
describe('Rendering', () => {
|
||||
describe('Menu', () => {
|
||||
it('should not crash when rendering no children at all', () => {
|
||||
renderTemplate(jsx`
|
||||
<Menu></Menu>
|
||||
`)
|
||||
})
|
||||
|
||||
it('should be possible to render a Menu using a default render prop', async () => {
|
||||
renderTemplate(jsx`
|
||||
<Menu v-slot="{ open }">
|
||||
|
||||
@@ -108,7 +108,7 @@ function _render({
|
||||
}
|
||||
|
||||
if (as === 'template') {
|
||||
children = flattenFragments(children as VNode[])
|
||||
children = flattenFragments(children ?? [])
|
||||
|
||||
if (Object.keys(incomingProps).length > 0 || Object.keys(attrs).length > 0) {
|
||||
let [firstChild, ...other] = children ?? []
|
||||
|
||||
Reference in New Issue
Block a user