The CSS Typed Object Model, part of Houdini, replaces stringly-typed style access with real typed objects. This reference covers the value types and the style-map APIs.
How it works
Instead of strings, styles are objects with numeric fields:
// old CSSOM — strings
el.style.width; // "100px" → must parse
// Typed OM — objects
el.computedStyleMap().get("width"); // CSSUnitValue { value: 100, unit: "px" }
el.attributeStyleMap.set("width", CSS.px(100));
The base class is CSSStyleValue. Concrete subtypes include CSSUnitValue (a number + unit),
CSSKeywordValue (an identifier like auto), CSSMathSum/CSSMathProduct (calc expressions),
CSSTransformValue and CSSColorValue. The CSS.px(...), CSS.percent(...), CSS.deg(...) and
CSS.number(...) factories build unit values directly.
Arithmetic and conversion
CSSNumericValue supports add, sub, mul, div, min, max:
- Compatible units reduce to a single
CSSUnitValue—CSS.px(10).add(CSS.px(5))→15px. - Incompatible units stay symbolic —
CSS.px(10).add(CSS.percent(50))→ aCSSMathSum(acalc()), because the result cannot be resolved without layout. .to(unit)converts within a unit family (e.g.CSS.cm(1).to("mm")→10mm).
Read computed values with the read-only element.computedStyleMap(); read/write inline values with
element.attributeStyleMap. Feature-detect with "computedStyleMap" in Element.prototype.