Skip to content
Bug reportNov 16, 2026· 0:16· 21 views

Lit styleMap: camelCase property with !important value is ignored on updates

0:16 total

Comments · 0

Be the first to comment.

Bug reportby SceneRecap AI

mediumlit-html styleMap directive update path. On updates, camelCase properties with an !important value may not be converted to their dash-case name before style.setProperty is called with the 'important' priority. The first render path works.
os: macOSdpr: 1locale: en-USbrowser: Chromium 151.0.7922.34library: lit@3 / lit-html styleMap directivetimezone: Europe/Berlinviewport: 1280x720issue_ref: github.com/lit/lit/issues/5427

Repro steps

  1. 1.Render an element with styleMap({ backgroundColor: '#ef4444 !important' }). The box renders red.
  2. 2.Update the styleMap to backgroundColor '#16a34a !important' (Green).
  3. 3.Update the styleMap to backgroundColor '#2563eb !important' (Blue).
  4. 4.Observe that the computed background stays rgb(239, 68, 68) after each update.

Expected

After each styleMap update, the box background changes to the new !important value: green (#16a34a) after update 1 and blue (#2563eb) after update 2.

Actual

The box stays red. After update 1 and update 2 the computed background is still rgb(239, 68, 68), the initial value. Only the first render applies the !important value.

Evidence

visualControl: on the initial render the box is red and its label reads 'Expected: Red (#ef4444)' with 'updates: 0'. This shows that styleMap with !important works on first render.
visualPage context title reads 'Initial render: red background (styleMap !important works on first render)'.
visualCode line reads styleMap({ backgroundColor: '#16a34a !important' }) with 'updates: 1'. The label reads 'Expected: Green (#16a34a)', but the box is still red.
visualStatus panel shows 'BUG (update 1)'. It says the computed background is still rgb(239, 68, 68) and the old value is stuck.
visualCode line reads styleMap({ backgroundColor: '#2563eb !important' }) with 'updates: 2'. The label reads 'Expected: Blue (#2563eb)', but the box is still red.
visualStatus panel shows 'BUG (update 2)'. It reports the computed background is still rgb(239, 68, 68). The state stays the same through the end of the recording.
Issue markdown (copy-paste ready)
## Summary
In lit@3, the `styleMap` directive applies a camelCase property with an `!important` value on first render. It ignores the same property on later updates. See github.com/lit/lit/issues/5427.

## Environment
- Chromium 151.0.7922.34, macOS
- Viewport 1280x720, DPR 1
- lit@3 / lit-html `styleMap` directive

## Steps to reproduce
1. Render an element with `styleMap({ backgroundColor: '#ef4444 !important' })`. The box is red (1.0s).
2. Update to `styleMap({ backgroundColor: '#16a34a !important' })` (7.0s).
3. Update to `styleMap({ backgroundColor: '#2563eb !important' })` (9.0s).
4. Check the computed background color (15.0s).

## Expected
The box turns green after update 1. It turns blue after update 2.

## Actual
The box stays red. After both updates the computed background is still `rgb(239, 68, 68)`.

## Evidence
- 1.0s: Control case. The initial render is red, 'updates: 0'. `!important` works on first render.
- 7.0s: 'updates: 1' and the label reads 'Expected: Green (#16a34a)'. The status panel shows 'BUG (update 1)' with the computed background still `rgb(239, 68, 68)`.
- 9.0s: 'updates: 2' and the label reads 'Expected: Blue (#2563eb)'. The status panel shows 'BUG (update 2)' with the computed background still `rgb(239, 68, 68)`.
- 15.0s: There is no change. The old value is stuck.

## Suggested area
The `styleMap` update path in lit-html. On update, camelCase keys with `!important` may not be converted to dash-case before `style.setProperty(name, value, 'important')` is called.

*Recorded with SceneRecap.*

Your recordings could explain themselves too.

Free plan · silent recordings welcome · bug reports included.

Try SceneRecap free →
Lit styleMap: camelCase property with !important value is ignored on updates · SceneRecap