Anne van Kesteren

CSSOM: API for CSS values

The CSSOM draft defines a whole lot more serialization details now, though I have not filled in all the red boxes yet. In part this is because it is somewhat boring work, but there are also some open questions. E.g. whether to serialize <color> values as it is done for the <canvas> element (using the hexadecimal notation) or using the rgb() notation so we can represent more than 255 values per component.

Another thing I have wanted to start tackling for a while now is CSS value APIs (see also W3CTP: CSSOM). The initial idea was to invent some new kind of DOMString, but a long discussion with the ECMAScript guys ruled that out. It would likely break too much deployed scripts.

The new idea is to introduce a values attribute on CSSStyleDeclaration that returns a CSSStyleDeclarationValue object which is in all respects equivalent to CSSStyleDeclaration except that the CSS property attributes return CSSValue objects. Potentially special CSSValue objects if it is deemed worth of a proper interface. E.g. for the 'color' property a CSSValue object would be returned that also implements CSSColorValue. The eventual result is something like this: -= .1

(There are quite a few problems to be sorted out before this is done. Hopefully I can make some progress on that tomorrow.)


  1. Thanks for working on this stuff!

    Posted by Michael A. Puls II at

  2. Would be great, in fact.

    Posted by François at

  3. In ECMAScript everything is a potential object.
    Why not make a CSSColor object?

    CSSColor {
    	toString() { returns value }
    	red: integer
    	green: integer
    	blue: integer
    	alpha: floating

    Posted by DJMaze at

  4. See the long discussion referenced in the post. That was the initial plan, but it was deemed that it would break too much. E.g. instanceof or the in operator.

    Posted by Anne at