Philipp Spiess 3b61277e7a
Don't crash when setting JS theme value to null (#16210)
Closes #16035

In v3 it was possible to unset a specific color namespace by setting
doing something like this:

```js
export default {
  theme: {
    extend: {
      colors: {
        red: null,
      },
    },
  },
}
```

This pattern would crash in v4 right now due to the theme access
function not being able to work on the red property being a `null`. This
PR fixes this crash.

However it leaves the behavior as-is for now so that the red namespace
_defined via CSS will still be accessible_. This is technically
different from v3 but fixing this would be more work as we only allow
unsetting top-level namespaces in the interop layer (via the
non-`extend`-theme-object). I would recommend migrating to the v4 API
for doing these partial namespace resets if you want to get rid of the
defaults in v4:

```css
@theme {
  --color-red-*: initial;
}
```

## Test plan

The crash was mainly captured via the test in `compat/config.test.ts`
but I've added two more tests across the different levels of
abstractions so that it's clear what `null` should be doing.

---------

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2025-02-04 15:43:48 +01:00
..
2025-02-01 12:38:55 +01:00
2024-12-11 15:27:20 +01:00