wiki:Cleanroom implement CSS Custom Properties

Attendee: eric_carlson, hober, dhyatt, Zoltan, asterns, abucur

Motivations

  • Custom properties allow CSS feature polyfills to be implemented without having to parse & simulate inheritance.

Status of Spec

  • Firefox implements the full specification because CSS WG has stripped down the parts Firefox didn't implement.
  • New syntax uses "--" prefix to define a new CSS variable and uses "var()" function to reference a variable. - There was a very long thread on CSS WG.
  • Custom properties are all inheritable - this may pose an implementation challenge; we probably need a chain of custom property bundles.
  • Custom properties aren't exposed in computed style.
  • It seems weird that a custom property can't refer to another custom property defined in the same selector.

Historical Implementations

There are two historical implementations: the one implemented by hyatt and someone at Google. The Google implementation had many architectural problems.

The hyatt implementation was taken out of the trunk because CSS WG could not agree on the exact syntax. It also supported changing the value of a CSS variable in scripts. var() function parser could be pulled in from the hyatt's implementation but the patch may not apply well due to it being so old.

Concerns

  • Websites that don't use variables shouldn't slow down.
  • Breaking cycle - appears to be spec'ed but invalidating the value with cycles might be challenging in the implementation.
  • It's not clear what values are available at the time of defining custom properties.
  • There is no self-referencing custom properties; values of variables are determined before inheritance happens for the custom properties.
  • Can we have tests just for custom properties?
  • What happens when you copy & paste content with custom properties? - We use computed style so this shouldn't be an issue.

Who should implement?

  • Hyatt says this would be fun to implement.
  • Alan says he might be able to find people who can help.

Future Direction

  • Style mutation observer
    • Tricky because it may expose the timing of style resolution
    • Authors may want to observe changes to custom properties before they are evaluated so that they can manipulate them, etc...
Last modified 3 years ago Last modified on Apr 15, 2014 11:51:41 AM