Skip to content

Commit 60807bf

Browse files
authored
fix(css): return undefined if there is no className (#11602)
1 parent 94fe4bb commit 60807bf

7 files changed

Lines changed: 13 additions & 36 deletions

File tree

packages/react-core/src/components/List/__tests__/__snapshots__/ListItem.test.tsx.snap

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ exports[`Matches snapshot with icon 1`] = `
2323

2424
exports[`Matches snapshot without icon 1`] = `
2525
<DocumentFragment>
26-
<li
27-
class=""
28-
>
26+
<li>
2927
<span>
3028
List item content
3129
</span>

packages/react-core/src/components/Nav/__tests__/__snapshots__/Nav.test.tsx.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,6 @@ exports[`Nav Nav List with flyout 1`] = `
10171017
</li>
10181018
</ul>
10191019
<div
1020-
class=""
10211020
data-popper-escaped="true"
10221021
data-popper-placement="right-start"
10231022
data-popper-reference-hidden="true"

packages/react-core/src/components/SearchInput/__tests__/__snapshots__/SearchInput.test.tsx.snap

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
exports[`SearchInput advanced search 1`] = `
44
<DocumentFragment>
5-
<div
6-
class=""
7-
>
5+
<div>
86
<div
97
class="pf-v6-c-input-group"
108
>
@@ -145,7 +143,6 @@ exports[`SearchInput advanced search 1`] = `
145143
exports[`SearchInput advanced search with custom attributes 1`] = `
146144
<DocumentFragment>
147145
<div
148-
class=""
149146
data-testid="test-id"
150147
>
151148
<div
@@ -282,7 +279,6 @@ exports[`SearchInput advanced search with custom attributes 1`] = `
282279
</div>
283280
</div>
284281
<div
285-
class=""
286282
data-popper-escaped="true"
287283
data-popper-placement="bottom-start"
288284
data-popper-reference-hidden="true"
@@ -490,9 +486,7 @@ exports[`SearchInput advanced search with custom attributes 1`] = `
490486

491487
exports[`SearchInput renders search input in strict mode 1`] = `
492488
<DocumentFragment>
493-
<div
494-
class=""
495-
>
489+
<div>
496490
<div
497491
class="pf-v6-c-input-group"
498492
>

packages/react-core/src/components/ToggleGroup/__tests__/__snapshots__/ToggleGroupItemElement.test.tsx.snap

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
exports[`empty 1`] = `
44
<DocumentFragment>
5-
<span
6-
class=""
7-
/>
5+
<span />
86
</DocumentFragment>
97
`;
108

packages/react-core/src/layouts/Flex/__tests__/__snapshots__/Flex.test.tsx.snap

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ exports[`Flex Nested flex 1`] = `
88
<div
99
class="pf-v6-l-flex"
1010
>
11-
<div
12-
class=""
13-
>
11+
<div>
1412
Test
1513
</div>
1614
</div>
@@ -23,9 +21,7 @@ exports[`Flex Simple flex with single item 1`] = `
2321
<div
2422
class="pf-v6-l-flex"
2523
>
26-
<div
27-
class=""
28-
>
24+
<div>
2925
Test
3026
</div>
3127
</div>
@@ -37,9 +33,7 @@ exports[`Flex alternative component 1`] = `
3733
<ul
3834
class="pf-v6-l-flex"
3935
>
40-
<li
41-
class=""
42-
>
36+
<li>
4337
Test
4438
</li>
4539
</ul>

packages/react-drag-drop/src/components/DragDrop/__tests__/__snapshots__/DragDrop.test.tsx.snap

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ exports[`renders some divs 1`] = `
66
class="pf-c-droppable pf-m-dragging"
77
>
88
<div>
9-
<div
10-
class=""
11-
>
9+
<div>
1210
<button
1311
aria-describedby="DndDescribedBy-0"
1412
aria-disabled="false"
@@ -46,9 +44,7 @@ exports[`renders some divs 1`] = `
4644
</button>
4745
one
4846
</div>
49-
<div
50-
class=""
51-
>
47+
<div>
5248
<button
5349
aria-describedby="DndDescribedBy-0"
5450
aria-disabled="false"
@@ -86,9 +82,7 @@ exports[`renders some divs 1`] = `
8682
</button>
8783
two
8884
</div>
89-
<div
90-
class=""
91-
>
85+
<div>
9286
<button
9387
aria-describedby="DndDescribedBy-0"
9488
aria-disabled="false"

packages/react-styles/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
*
33
* @param {any} args list of objects, string, or arrays to reduce
44
*/
5-
export function css(...args: any): string {
6-
// Adapted from https://github.com/JedWatson/classnames/blob/master/index.js
5+
export function css(...args: any): string | undefined {
6+
// Adapted from https://github.com/JedWatson/classnames/blob/main/index.js
77
const classes = [] as string[];
88
const hasOwn = {}.hasOwnProperty;
99

@@ -26,5 +26,5 @@ export function css(...args: any): string {
2626
}
2727
});
2828

29-
return classes.join(' ');
29+
return classes.join(' ') || undefined;
3030
}

0 commit comments

Comments
 (0)