Skip to content

fix: parse string style in custom attributes#367

Merged
tristan-mouchet merged 1 commit into
developfrom
fix/custom-attribute-style-string
Jun 17, 2026
Merged

fix: parse string style in custom attributes#367
tristan-mouchet merged 1 commit into
developfrom
fix/custom-attribute-style-string

Conversation

@tristan-mouchet

Copy link
Copy Markdown
Collaborator

Summary

A layer's style custom attribute is stored as a raw CSS string, but it was being applied directly to React's style prop, which requires an object. On render paths that spread props without overriding style (e.g. images, inputs, iframes), the string leaked to the DOM and crashed server-side rendering with The style prop expects a mapping from style properties to values, not a string.

Changes

  • Add parseStyleStringToObject() util that parses an inline CSS string into a React style object (splits on the first colon so values with colons like URLs survive; preserves --custom-properties verbatim).
  • Add applyCustomAttributes() util that maps HTML attribute names to their JSX equivalents and, for a string style, parses and merges it into any existing computed style.
  • Replace the four duplicated customAttributes loops (element + iframe) in LayerRenderer and LayerRendererPublic with the shared helper.

Test plan

  • Add a custom attribute style = color: red; margin-top: 10px to a layer — element styles correctly, no console error on canvas
  • Open the page in preview/published render — no server-side style prop error
  • style value with a colon, e.g. background: url(https://x/y) — full URL preserved
  • CSS variable, e.g. --accent: #f00 — preserved without camelCasing
  • Custom attr style merges with the layer's existing computed styles

A layer's `style` custom attribute is stored as a raw CSS string and was
applied directly to React's style prop, which expects an object. Render
paths that spread props without overriding style leaked the string to the
DOM and crashed SSR. Parse and merge it into the computed style instead.
@tristan-mouchet tristan-mouchet added the Bug Something isn't working label Jun 17, 2026
@tristan-mouchet tristan-mouchet self-assigned this Jun 17, 2026
@tristan-mouchet tristan-mouchet merged commit a13bd63 into develop Jun 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant