Skip to content

Commit

Permalink
Gracefully handle empty "xstyle" prop values (Part 2) (facebook#23279)
Browse files Browse the repository at this point in the history
facebook#23190 misses if entry is undefined or null. This fixes this issue.
  • Loading branch information
lunaruan authored and zhengjitf committed Apr 15, 2022
1 parent 6b0753e commit 08ed325
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ describe('Stylex plugin utils', () => {
"sources": Array [],
}
`);

expect(getStyleXData([undefined])).toMatchInlineSnapshot(`
Object {
"resolvedStyles": Object {},
"sources": Array [],
}
`);
});

it('should support simple style objects', () => {
Expand Down
4 changes: 4 additions & 0 deletions packages/react-devtools-shared/src/backend/StyleX/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export function crawlData(

if (isArray(data)) {
data.forEach(entry => {
if (entry == null) {
return;
}

if (isArray(entry)) {
crawlData(entry, sources, resolvedStyles);
} else {
Expand Down

0 comments on commit 08ed325

Please sign in to comment.