Skip to content

fix(publisher): keep custom properties with underscores or a leading --_ - #617

Open
ehnruiz wants to merge 1 commit into
CoreBunch:mainfrom
ehnruiz:fix/custom-property-underscores
Open

ehnruiz wants to merge 1 commit into
CoreBunch:mainfrom
ehnruiz:fix/custom-property-underscores

Conversation

@ehnruiz

@ehnruiz ehnruiz commented Oct 11, 2026 •

Copy link
Copy Markdown

Summary

Fixes #615. The property-name gate (isEmittableProperty in src/core/publisher/classCss.ts) used one pattern for every name, /^-{0,2}[a-zA-Z][a-zA-Z0-9-]*$/. That pattern rejects any custom property containing _ or starting with --_, so the stylesheet importer and the publisher both dropped them, and every var() on them resolved to nothing. Webflow exports generate both forms throughout (--brand---ds_mapped---background--page, --_mapped---button--fill).

  • Custom properties (--…) are now checked against /^--[a-zA-Z0-9_-]+$/. Standard property names keep the stricter pattern, and the behavior / -moz-binding denylist still applies to both.
  • toKebab now passes custom property names through unchanged. Custom properties are case-sensitive, and --brandColor was emitted as --brand-color, which broke var(--brandColor). I found this while reproducing Publisher drops CSS custom properties with an underscore or a leading --_ (classCss VALID_PROPERTY_RE) #615. It is the same problem (custom property names not emitted as authored), so it is in this PR. Happy to split it out if you prefer.

Impact: an imported site keeps all of its custom properties. In the real 7-page Webflow site behind #615, that is the 186 of 322 design-system variables that were being dropped.

Verification

  • bun run build (exit 0)
  • bun test on this commit (08041d3): 7040 pass, 0 fail (exit 0) on a quiet machine. An earlier run on a loaded machine had 15 timeouts in MCP, auth, sanitize and language-service tests; those files also passed on their own.
  • bun run lint (exit 0)
  • Docker/deployment check, if relevant (not relevant)

New tests fail on main and pass here:

Checklist

  • Tests cover behavior changes.
  • Docs were updated when behavior, config, deployment, or public surfaces changed. No docs change needed: docs/features/html-import.md describes the gate by name, not by pattern.
  • No compatibility shim was added for old pre-release behavior.
  • No secrets, local databases, uploads, or generated artifacts are included.

The property-name gate rejected any custom property containing `_` or
starting with `--_`, so the importer and the publisher dropped them and
every var() on them resolved to nothing. Custom properties are now checked
against the spec's identifier rule; standard property names keep the
stricter pattern and the denylist still applies.

Custom property names also pass through toKebab unchanged, so
`--brandColor` is no longer emitted as `--brand-color`.

Fixes CoreBunch#616
@ehnruiz
ehnruiz marked this pull request as ready for review October 11, 2026 00:23
@ehnruiz

ehnruiz commented Oct 15, 2026

Copy link
Copy Markdown
Author

@DavidBabinec, three small Site Import fixes found on a real Webflow import: #617 (custom properties with _ or --_ were dropped), #618 (color token var() refs), #620 (font token refs, stacked on #618). All rebased on main with tests. Happy to change anything.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant