Skip to content

[dom2] Can't set CSS custom properties #39

@ComedyTomedy

Description

@ComedyTomedy

dom2/style will only set properties that goog.style/setStyle recognises - anything else silently vanishes. This makes it impossible to use custom properties ("CSS variables"), and seems to affect browser-prefixed props too (I quickly tested -moz-transition, might be wrong about this).

Here are 2 attempts that don't work:

(dom/style {:--size (str x)})

(dom/props {:style (str "--size: " x)})

And one attempt that did:

(dom/set-attribute-ns dom/node
   nil "style" (str "--size: " x))

One possible fix might be for dom/set-property! to join style rules into a k: v; k2: v2 form and use set-attribute-ns to inject them as a string. It feels slightly hacky, and perhaps bypasses some clever internals of Google Closure (?), but it would solve the problem without styles overwriting oneanother.

(PS: I'm enjoying Electric v much, I'm not a dev, don't work in tech, and never used Clojure beyond toy examples, but Electric has revived my enthusiasm for a personal project that I abandoned last year. Thank you for everything!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions