johanholmerin / style9

CSS-in-JS compiler inspired by Meta's stylex
MIT License
570 stars 27 forks source link

Unclear behavior when using conditionals #22

Closed edvinerikson closed 3 years ago

edvinerikson commented 3 years ago

There seems to be some weird behavior going on when using conditionals.

Given these styles

const styles = style9.create({
  primaryButton: {
    ":hover": {
      boxShadow: "var(--box-shadow-hover)"
    }
  },
  secondaryButton: {
    ":hover": {
      boxShadow: "var(--box-shadow-hover)"
    }
  },
});

I would expect these two invocations to return the same string

const st1 = styles(
      true && 'primaryButton',
      false && 'secondaryButton'
  );
  const st2 = styles(
      true && 'primaryButton'
  );

// st1 === st2 => false

// st1 === "" => true

// st2 === "c17j9v3m " => true
johanholmerin commented 3 years ago

Good catch. Fixed in 0.6.2