Instatic icon indicating copy to clipboard operation
Instatic copied to clipboard

Publisher drops CSS custom properties with an underscore or a leading --_ (classCss VALID_PROPERTY_RE)

Open ehnruiz opened this issue 1 month ago • 0 comments

Summary

The publisher silently drops any CSS custom property whose name contains an underscore or starts with --_. Every var() that refers to one then resolves to nothing. Both forms are valid CSS custom property names, and Webflow exports generate them throughout (for example --brand---ds_mapped---background--page and --_mapped---button--fill), so an imported Webflow site loses much of its styling with no warning.

Steps to reproduce

  1. Import a static site (Site Import, or paste HTML) whose stylesheet contains:
    .card {
      --card_bg: #0575d6;
      --_accent: #fc834b;
      --plain-ok: #161617;
      background: var(--card_bg);
      border-color: var(--_accent);
      color: var(--plain-ok);
    }
    
  2. Publish and open the published page's style-*.css.

Expected behavior

All three custom properties are emitted as authored. The spec allows any -- identifier, underscores included.

Actual behavior

Only --plain-ok is emitted. --card_bg and --_accent are dropped, so background and border-color fall back to their initial values. Nothing in the import review or the import log mentions it.

The cause appears to be VALID_PROPERTY_RE in src/core/publisher/classCss.ts:57:

const VALID_PROPERTY_RE = /^-{0,2}[a-zA-Z][a-zA-Z0-9-]*$/

That pattern fits standard properties, but it rejects custom properties with _, and any that start with --_. Testing custom properties (prop.startsWith('--')) against something like /^--[A-Za-z0-9_-]+$/ would keep them while still rejecting junk.

Scale, from a real 7-page Webflow site: exactly the 186 of 322 design-system custom properties with an underscore in their name were dropped, and the other 136 survived. Buttons, inputs and section backgrounds lost their colors. Renaming _ to - in every name and reference before import makes all of them survive, which confirms the cause.

Version or commit

0.0.20 (f92e8dc, current main)

Deployment mode

Local, bun run start (SQLite), Bun 1.4.2, macOS

ehnruiz avatar Oct 10 '26 19:10 ehnruiz