diff --git a/packages/@stylexjs/babel-plugin/__tests__/evaluation-import-test.js b/packages/@stylexjs/babel-plugin/__tests__/evaluation-import-test.js index dc0fecb89..2cfdc4697 100644 --- a/packages/@stylexjs/babel-plugin/__tests__/evaluation-import-test.js +++ b/packages/@stylexjs/babel-plugin/__tests__/evaluation-import-test.js @@ -402,7 +402,7 @@ describe('Evaluation of imported values works based on configuration', () => { }); const styles = { color: color => [{ - "--__hashed_var__1jqb1tb": color != null ? "__hashed_var__1w8wjxo" : color, + "--__hashed_var__1jqb1tb": color != null ? "__hashed_var__1w8wjxo" : "", $$css: true }, { "--x---__hashed_var__1jqb1tb": color != null ? color : undefined diff --git a/packages/@stylexjs/babel-plugin/__tests__/transform-process-test.js b/packages/@stylexjs/babel-plugin/__tests__/transform-process-test.js index 58c30ac1f..efb507ccb 100644 --- a/packages/@stylexjs/babel-plugin/__tests__/transform-process-test.js +++ b/packages/@stylexjs/babel-plugin/__tests__/transform-process-test.js @@ -240,7 +240,7 @@ describe('@stylexjs/babel-plugin', () => { $$css: "components/main.js:71" }, dynamic: color => [{ - "color-kMwMTN": color != null ? "color-x14rh7hd" : color, + "color-kMwMTN": color != null ? "color-x14rh7hd" : "", $$css: "components/main.js:74" }, { "--x-color": color != null ? color : undefined @@ -333,7 +333,7 @@ describe('@stylexjs/babel-plugin', () => { $$css: "main.js:71" }, dynamic: color => [{ - "color-kMwMTN": color != null ? "color-x14rh7hd" : color, + "color-kMwMTN": color != null ? "color-x14rh7hd" : "", $$css: "main.js:74" }, { "--x-color": color != null ? color : undefined @@ -781,7 +781,7 @@ describe('@stylexjs/babel-plugin', () => { $$css: "main.js:71" }, dynamic: color => [{ - "color-kMwMTN": color != null ? "color-x14rh7hd" : color, + "color-kMwMTN": color != null ? "color-x14rh7hd" : "", $$css: "main.js:74" }, { "--x-color": color != null ? color : undefined diff --git a/packages/@stylexjs/babel-plugin/__tests__/transform-stylex-create-test.js b/packages/@stylexjs/babel-plugin/__tests__/transform-stylex-create-test.js index 5879276c6..a79c4fda7 100644 --- a/packages/@stylexjs/babel-plugin/__tests__/transform-stylex-create-test.js +++ b/packages/@stylexjs/babel-plugin/__tests__/transform-stylex-create-test.js @@ -3645,7 +3645,7 @@ describe('@stylexjs/babel-plugin', () => { }; export const styles = { root: color => [_temp, { - kMwMTN: color != null ? "x14rh7hd" : color, + kMwMTN: color != null ? "x14rh7hd" : "", $$css: true }, { "--x-color": color != null ? color : undefined @@ -3700,7 +3700,7 @@ describe('@stylexjs/babel-plugin', () => { "import * as stylex from '@stylexjs/stylex'; export const styles = { one: color => [{ - kMwMTN: color != null ? "x14rh7hd" : color, + kMwMTN: color != null ? "x14rh7hd" : "", $$css: true }, { "--x-color": color != null ? color : undefined @@ -3758,8 +3758,8 @@ describe('@stylexjs/babel-plugin', () => { "import * as stylex from '@stylexjs/stylex'; export const styles = { root: (bgColor, otherColor) => [{ - "--background-color": bgColor != null ? "xwn82o0" : bgColor, - "--otherColor": otherColor != null ? "xp3hsad" : otherColor, + "--background-color": bgColor != null ? "xwn82o0" : "", + "--otherColor": otherColor != null ? "xp3hsad" : "", $$css: true }, { "--x---background-color": bgColor != null ? bgColor : undefined, @@ -3822,7 +3822,7 @@ describe('@stylexjs/babel-plugin', () => { "import * as stylex from '@stylexjs/stylex'; export const styles = { root: width => [{ - kzqmXN: width != null ? "x5lhr3w" : width, + kzqmXN: width != null ? "x5lhr3w" : "", $$css: true }, { "--x-width": (val => typeof val === "number" ? val + "px" : val != null ? val : undefined)(width) @@ -3874,7 +3874,7 @@ describe('@stylexjs/babel-plugin', () => { }; export const styles = { root: width => [_temp, { - kzqmXN: width != null ? "x5lhr3w" : width, + kzqmXN: width != null ? "x5lhr3w" : "", $$css: true }, { "--x-width": (val => typeof val === "number" ? val + "px" : val != null ? val : undefined)(width), @@ -3953,7 +3953,7 @@ describe('@stylexjs/babel-plugin', () => { import { vars } from 'vars.stylex.js'; export const styles = { root: width => [{ - "--x1anmu0j": width != null ? "x5fq457" : width, + "--x1anmu0j": width != null ? "x5fq457" : "", $$css: true }, { "--x---x1anmu0j": width != null ? width : undefined @@ -4407,7 +4407,7 @@ describe('@stylexjs/babel-plugin', () => { }; export const styles = { root: (color, isDark) => [_temp, { - kMwMTN: (isDark ? color : 'black') != null ? "x14rh7hd" : isDark ? color : 'black', + kMwMTN: (isDark ? color : 'black') != null ? "x14rh7hd" : "", $$css: true }, { "--x-backgroundColor": (isDark ? 'black' : 'white') != null ? isDark ? 'black' : 'white' : undefined, @@ -4577,8 +4577,8 @@ describe('@stylexjs/babel-plugin', () => { "import * as stylex from '@stylexjs/stylex'; export const styles = { root: color => [{ - kWkggS: color != null ? "x1j2k28p" : color, - kMwMTN: color != null ? "x1qvlgnj" : color, + kWkggS: color != null ? "x1j2k28p" : "", + kMwMTN: color != null ? "x1qvlgnj" : "", $$css: true }, { "--x-1e2mv7m": color != null ? color : undefined, @@ -4644,7 +4644,7 @@ describe('@stylexjs/babel-plugin', () => { "import * as stylex from '@stylexjs/stylex'; export const styles = { root: (hover, active, focus) => [{ - kMwMTN: (hover != null ? "x1qvlgnj " : hover) + (active != null ? "xx746rz " : active) + (focus != null ? "x152n5rj " : focus) + "x126ychx", + kMwMTN: (hover != null ? "x1qvlgnj " : "") + (active != null ? "xx746rz " : "") + (focus != null ? "x152n5rj " : "") + "x126ychx", $$css: true }, { "--x-1113oo7": hover != null ? hover : undefined, @@ -4737,8 +4737,8 @@ describe('@stylexjs/babel-plugin', () => { "import * as stylex from '@stylexjs/stylex'; export const styles = { foo: (a, b) => [{ - kxBb7d: a != null ? "xaigonn" : a, - kB1Fuz: b != null ? "x1p1099i" : b, + kxBb7d: a != null ? "xaigonn" : "", + kB1Fuz: b != null ? "x1p1099i" : "", $$css: true }, { "--x-1g451k2": a != null ? a : undefined, @@ -4801,7 +4801,7 @@ describe('@stylexjs/babel-plugin', () => { "import * as stylex from '@stylexjs/stylex'; export const styles = { foo: color => [{ - k8Qsv1: color != null ? "x1mzl164" : color, + k8Qsv1: color != null ? "x1mzl164" : "", $$css: true }, { "--x-163tekb": color != null ? color : undefined @@ -4847,7 +4847,7 @@ describe('@stylexjs/babel-plugin', () => { "import * as stylex from '@stylexjs/stylex'; export const styles = { foo: width => [{ - k8pbKx: width != null ? "x18fgbt0" : width, + k8pbKx: width != null ? "x18fgbt0" : "", $$css: true }, { "--x-msahdu": (val => typeof val === "number" ? val + "px" : val != null ? val : undefined)(width) @@ -4951,7 +4951,7 @@ describe('@stylexjs/babel-plugin', () => { "import * as stylex from '@stylexjs/stylex'; export const styles = { repro: color => [{ - kB1Fuz: color != null ? "x1p1099i" : color, + kB1Fuz: color != null ? "x1p1099i" : "", $$css: true }, { "--x-19erzii": color != null ? color : undefined @@ -5001,7 +5001,7 @@ describe('@stylexjs/babel-plugin', () => { "import * as stylex from '@stylexjs/stylex'; export const styles = { root: (a, b, c) => [{ - kzqmXN: "x11ymkkh " + "x38mdg9 " + (c != null ? "x1bai16n" : c), + kzqmXN: "x11ymkkh " + "x38mdg9 " + (c != null ? "x1bai16n" : ""), $$css: true }, { "--x-1xmrurk": (val => typeof val === "number" ? val + "px" : val != null ? val : undefined)('color-mix(' + color + ', blue)'), @@ -5083,7 +5083,7 @@ describe('@stylexjs/babel-plugin', () => { "import * as stylex from '@stylexjs/stylex'; export const styles = { root: (a, b, c) => [{ - kMwMTN: (a != null ? "x3d248p " : a) + (b != null ? "x1iuwwch " : b) + (c != null ? "x5268pl" : c), + kMwMTN: (a != null ? "x3d248p " : "") + (b != null ? "x1iuwwch " : "") + (c != null ? "x5268pl" : ""), $$css: true }, { "--x-4xs81a": a != null ? a : undefined, @@ -5167,7 +5167,7 @@ describe('@stylexjs/babel-plugin', () => { "import * as stylex from '@stylexjs/stylex'; export const styles = { root: (a, b, c) => [{ - kGuDYH: (a != null ? "xww4jgc " : a) + (b != null ? "xfqys7t " : b) + (c != null ? "x13w7uki" : c), + kGuDYH: (a != null ? "xww4jgc " : "") + (b != null ? "xfqys7t " : "") + (c != null ? "x13w7uki" : ""), $$css: true }, { "--x-19zvkyr": (val => typeof val === "number" ? val + "px" : val != null ? val : undefined)(a), @@ -5250,7 +5250,7 @@ describe('@stylexjs/babel-plugin', () => { "import * as stylex from '@stylexjs/stylex'; export const styles = { root: (a, b, c) => [{ - kGuDYH: ((a ? '16px' : undefined) != null ? "xww4jgc " : a ? '16px' : undefined) + ((b ? '18px' : undefined) != null ? "xqdov8i " : b ? '18px' : undefined) + ((c ? '20px' : undefined) != null ? "x1j86d60" : c ? '20px' : undefined), + kGuDYH: ((a ? '16px' : undefined) != null ? "xww4jgc " : "") + ((b ? '18px' : undefined) != null ? "xqdov8i " : "") + ((c ? '20px' : undefined) != null ? "x1j86d60" : ""), $$css: true }, { "--x-19zvkyr": (val => typeof val === "number" ? val + "px" : val != null ? val : undefined)(a ? '16px' : undefined), @@ -6042,9 +6042,9 @@ describe('@stylexjs/babel-plugin', () => { }); export const styles = { default: margin => [_temp, { - k71WvV: (margin != null ? "x17e2bsb " : margin) + "xtcj1g9", - k1K539: (margin != null ? "xg6eqc8 " : margin) + "xgrn1a3", - keTefX: (margin != null ? "x19ja4a5 " : margin) + "x2tye95", + k71WvV: (margin != null ? "x17e2bsb " : "") + "xtcj1g9", + k1K539: (margin != null ? "xg6eqc8 " : "") + "xgrn1a3", + keTefX: (margin != null ? "x19ja4a5 " : "") + "x2tye95", $$css: true }, { "--x-14mfytm": (val => typeof val === "number" ? val + "px" : val != null ? val : undefined)(margin), diff --git a/packages/@stylexjs/babel-plugin/__tests__/transform-stylex-defineConsts-test.js b/packages/@stylexjs/babel-plugin/__tests__/transform-stylex-defineConsts-test.js index 49aa8595b..988fae6b2 100644 --- a/packages/@stylexjs/babel-plugin/__tests__/transform-stylex-defineConsts-test.js +++ b/packages/@stylexjs/babel-plugin/__tests__/transform-stylex-defineConsts-test.js @@ -543,7 +543,7 @@ describe('@stylexjs/babel-plugin', () => { }; export const styles = { node: padding => [_temp, { - kmVPX3: padding != null ? "x1fozly0" : padding, + kmVPX3: padding != null ? "x1fozly0" : "", $$css: true }, { "--x-padding": (val => typeof val === "number" ? val + "px" : val != null ? val : undefined)(padding) @@ -603,7 +603,7 @@ describe('@stylexjs/babel-plugin', () => { import { breakpoints } from './constants.stylex'; export const styles = { node: color => [{ - kMwMTN: "xbs0o1n " + (color != null ? "x3d248p" : color), + kMwMTN: "xbs0o1n " + (color != null ? "x3d248p" : ""), $$css: true }, { "--x-4xs81a": color != null ? color : undefined diff --git a/packages/@stylexjs/babel-plugin/__tests__/transform-stylex-props-test.js b/packages/@stylexjs/babel-plugin/__tests__/transform-stylex-props-test.js index f6f2943b9..d74a91135 100644 --- a/packages/@stylexjs/babel-plugin/__tests__/transform-stylex-props-test.js +++ b/packages/@stylexjs/babel-plugin/__tests__/transform-stylex-props-test.js @@ -544,7 +544,7 @@ describe('@stylexjs/babel-plugin', () => { $$css: "npm-package:js/node_modules/npm-package/dist/components/Foo.react.js:4" }, opacity: opacity => [{ - "opacity-kSiTet": opacity != null ? "opacity-xb4nw82" : opacity, + "opacity-kSiTet": opacity != null ? "opacity-xb4nw82" : "", $$css: "npm-package:js/node_modules/npm-package/dist/components/Foo.react.js:7" }, { "--x-opacity": opacity != null ? opacity : undefined @@ -806,7 +806,7 @@ describe('@stylexjs/babel-plugin', () => { }); const styles = { color: c => [{ - kMwMTN: c != null ? "x14rh7hd" : c, + kMwMTN: c != null ? "x14rh7hd" : "", $$css: true }, { "--x-color": c != null ? c : undefined @@ -902,7 +902,7 @@ describe('@stylexjs/babel-plugin', () => { }); const styles = { opacity: o => [{ - kSiTet: o != null ? "xb4nw82" : o, + kSiTet: o != null ? "xb4nw82" : "", $$css: true }, { "--x-opacity": o != null ? o : undefined @@ -944,7 +944,7 @@ describe('@stylexjs/babel-plugin', () => { }); const styles = { opacity: o => [{ - kSiTet: o != null ? "xb4nw82" : o, + kSiTet: o != null ? "xb4nw82" : "", $$css: true }, { "--x-opacity": o != null ? o : undefined diff --git a/packages/@stylexjs/babel-plugin/src/visitors/stylex-create.js b/packages/@stylexjs/babel-plugin/src/visitors/stylex-create.js index 549c781e5..b18290c7b 100644 --- a/packages/@stylexjs/babel-plugin/src/visitors/stylex-create.js +++ b/packages/@stylexjs/babel-plugin/src/visitors/stylex-create.js @@ -421,7 +421,7 @@ export default function transformStyleXCreate( t.conditionalExpression( t.binaryExpression('!=', expr, t.nullLiteral()), t.stringLiteral(clsWithSpace), - expr, + t.stringLiteral(''), ), ); } else {