Skip to content

fix(css): return undefined if there is no className #11594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

exports[`ListItem should match snapshot (auto-generated) 1`] = `
<DocumentFragment>
<li
class=""
>
<li>
<span>
ReactNode
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,23 +183,17 @@ exports[`List inline list 1`] = `
<ul
class="pf-v6-c-list"
>
<li
class=""
>
<li>
<span>
First
</span>
</li>
<li
class=""
>
<li>
<span>
Second
</span>
</li>
<li
class=""
>
<li>
<span>
Third
</span>
Expand All @@ -215,23 +209,17 @@ exports[`List ordered list 1`] = `
class="pf-v6-c-list"
type="1"
>
<li
class=""
>
<li>
<span>
Apple
</span>
</li>
<li
class=""
>
<li>
<span>
Banana
</span>
</li>
<li
class=""
>
<li>
<span>
Orange
</span>
Expand All @@ -248,23 +236,17 @@ exports[`List simple list 1`] = `
<ul
class="pf-v6-c-list"
>
<li
class=""
>
<li>
<span>
First
</span>
</li>
<li
class=""
>
<li>
<span>
Second
</span>
</li>
<li
class=""
>
<li>
<span>
Third
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,6 @@ exports[`Nav Nav List with flyout 1`] = `
</li>
</ul>
<div
class=""
data-popper-escaped="true"
data-popper-placement="right-start"
data-popper-reference-hidden="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

exports[`SearchInput advanced search 1`] = `
<DocumentFragment>
<div
class=""
>
<div>
<div
class="pf-v6-c-input-group"
>
Expand Down Expand Up @@ -145,7 +143,6 @@ exports[`SearchInput advanced search 1`] = `
exports[`SearchInput advanced search with custom attributes 1`] = `
<DocumentFragment>
<div
class=""
data-testid="test-id"
>
<div
Expand Down Expand Up @@ -282,7 +279,6 @@ exports[`SearchInput advanced search with custom attributes 1`] = `
</div>
</div>
<div
class=""
data-popper-escaped="true"
data-popper-placement="bottom-start"
data-popper-reference-hidden="true"
Expand Down Expand Up @@ -478,9 +474,7 @@ exports[`SearchInput advanced search with custom attributes 1`] = `

exports[`SearchInput renders search input in strict mode 1`] = `
<DocumentFragment>
<div
class=""
>
<div>
<div
class="pf-v6-c-input-group"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

exports[`empty 1`] = `
<DocumentFragment>
<span
class=""
/>
<span />
</DocumentFragment>
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ exports[`Flex Nested flex 1`] = `
<div
class="pf-v6-l-flex"
>
<div
class=""
>
<div>
Test
</div>
</div>
Expand All @@ -23,9 +21,7 @@ exports[`Flex Simple flex with single item 1`] = `
<div
class="pf-v6-l-flex"
>
<div
class=""
>
<div>
Test
</div>
</div>
Expand All @@ -37,9 +33,7 @@ exports[`Flex alternative component 1`] = `
<ul
class="pf-v6-l-flex"
>
<li
class=""
>
<li>
Test
</li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ exports[`renders some divs 1`] = `
class="pf-c-droppable pf-m-dragging"
>
<div>
<div
class=""
>
<div>
<button
aria-describedby="DndDescribedBy-0"
aria-disabled="false"
Expand Down Expand Up @@ -46,9 +44,7 @@ exports[`renders some divs 1`] = `
</button>
one
</div>
<div
class=""
>
<div>
<button
aria-describedby="DndDescribedBy-0"
aria-disabled="false"
Expand Down Expand Up @@ -86,9 +82,7 @@ exports[`renders some divs 1`] = `
</button>
two
</div>
<div
class=""
>
<div>
<button
aria-describedby="DndDescribedBy-0"
aria-disabled="false"
Expand Down
6 changes: 3 additions & 3 deletions packages/react-styles/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
*
* @param {any} args list of objects, string, or arrays to reduce
*/
export function css(...args: any): string {
// Adapted from https://github.com/JedWatson/classnames/blob/master/index.js
export function css(...args: any): string | undefined {
// Adapted from https://github.com/JedWatson/classnames/blob/main/index.js
const classes = [] as string[];
const hasOwn = {}.hasOwnProperty;

Expand All @@ -26,5 +26,5 @@ export function css(...args: any): string {
}
});

return classes.join(' ');
return classes.join(' ') || undefined;
}
Loading