@samitouri / QOS-React-2 / commits / 934f72221d

Gracefully handle empty "xstyle" prop values (#23190)

Brian Vaughn committed Jan 26, 2022 at 13:54 UTC 934f72221df0a006a96e9be70e5dae72aa060ab3
2 files changed +27
packages/react-devtools-shared/src/backend/StyleX/__tests__/utils-test.js
+23
@@ -33,6 +33,29 @@ describe('Stylex plugin utils', () => {
33 });
34 });
35
36 + it('should gracefully handle empty values', () => {
37 + expect(getStyleXData(null)).toMatchInlineSnapshot(`
38 + Object {
39 + "resolvedStyles": Object {},
40 + "sources": Array [],
41 + }
42 + `);
43 +
44 + expect(getStyleXData(undefined)).toMatchInlineSnapshot(`
45 + Object {
46 + "resolvedStyles": Object {},
47 + "sources": Array [],
48 + }
49 + `);
50 +
51 + expect(getStyleXData('')).toMatchInlineSnapshot(`
52 + Object {
53 + "resolvedStyles": Object {},
54 + "sources": Array [],
55 + }
56 + `);
57 + });
58 +
59 it('should support simple style objects', () => {
60 defineStyles(`
61 .foo {
packages/react-devtools-shared/src/backend/StyleX/utils.js
+4
@@ -29,6 +29,10 @@ export function crawlData(
29 sources: Set<string>,
30 resolvedStyles: Object,
31 ): void {
32 + if (data == null) {
33 + return;
34 + }
35 +
36 if (isArray(data)) {
37 data.forEach(entry => {
38 if (isArray(entry)) {