#1166·stitches

getCssText is broken when using `all: unset`

Author: vavdavCreated Jan 6, 2025Updated Jan 6, 2025

Bug report

Describe the bug

I wanted to use getCssText to replicate styles into pip window and found this bug. When there is all: unset the order of declarations is not correct in chrome, because it expands all declarations.

More info here: https://stackoverflow.com/questions/79332575/wrong-order-of-css-declarations-when-using-all-unset-and-csstext

To Reproduce

  1. declare component like this const StyledButton = styled('div', {all: 'unset', borderRadius: '12px'})
  2. call getCssText
  3. explore the output and see the order of declarations in chrome

Expected behavior

Order is correct

System information

  • Browser (if applies) chrome

Additional context

It is probably mostly a bug in Chrome as it wrongly returns value of rule.cssText so this function can not be used in that case. Adding it here for others as it is currently not maintained anymore.