Skip to content

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

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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;
}
18 changes: 1 addition & 17 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11475,23 +11475,7 @@ __metadata:
languageName: node
linkType: hard

"glob@npm:^11.0.1":
version: 11.0.1
resolution: "glob@npm:11.0.1"
dependencies:
foreground-child: "npm:^3.1.0"
jackspeak: "npm:^4.0.1"
minimatch: "npm:^10.0.0"
minipass: "npm:^7.1.2"
package-json-from-dist: "npm:^1.0.0"
path-scurry: "npm:^2.0.0"
bin:
glob: dist/esm/bin.mjs
checksum: 10c0/2b32588be52e9e90f914c7d8dec32f3144b81b84054b0f70e9adfebf37cd7014570489f2a79d21f7801b9a4bd4cca94f426966bfd00fb64a5b705cfe10da3a03
languageName: node
linkType: hard

"glob@npm:^11.0.0":
"glob@npm:^11.0.0, glob@npm:^11.0.1":
version: 11.0.1
resolution: "glob@npm:11.0.1"
dependencies:
Expand Down
Loading