Introducing css-typed-om, a complete and WPT-tested polyfill for CSS Typed OM Developer Bramus Van Damme released css-typed-om, a complete, standalone, Web Platform Test-tested polyfill for the CSS Typed Object Model, installable via npm as css-typed-om. The polyfill patches window.CSS, Element.prototype.computedStyleMap, HTMLElement.prototype.attributeStyleMap and all CSS Typed OM classes, addressing Firefox's incomplete native implementation, which remains behind the layout.css.typed-om.enabled flag per Firefox bug 1278697, and missing CSSColorValue subclasses such as CSSRGB and CSSOKLCH. Van Damme said the spec's scope — a full CSS tokenizer, calc() expression simplifier, 2D/3D matrix math and WebIDL interface rules — had made a hand-written polyfill too large an undertaking until AI assistance made it feasible. Being a big fan of the CSS Typed OM https://developer.mozilla.org/en-US/docs/Web/API/CSS Typed OM API , I’ve wanted a proper polyfill for it for years. Just before my summer vacation back in July, with the help of Gemini/Antigravity, I finally built one: css-typed-om https://github.com/bramus/css-typed-om-polyfill . ~ the-problem Why CSS Typed OM? And why a polyfill? If you’ve ever read or manipulated styles in JavaScript using element.style or window.getComputedStyle , you know the pain of dealing with strings. Want to read an element’s width and add 20px to it? You have to parse the string, strip the unit, convert it to a number, do the math, and concatenate it back into a string. Throw calc , transform matrices, or modern color spaces into the mix, and string manipulation quickly falls apart. js const styles = getComputedStyle $el ; const opacity = styles.getPropertyValue 'opacity' ; console.log opacity ; // '0.2' console.log typeof opacity ; // String ? That’s where the CSS Typed Object Model CSS Typed OM https://developer.chrome.com/docs/css-ui/cssom comes in. Instead of strings, it exposes CSS values as typed JavaScript objects — such as CSSUnitValue , CSSMathSum , CSSTransformValue , and CSSKeywordValue — through element.attributeStyleMap , element.computedStyleMap , and unit factory functions like CSS.px 20 . js const styles = $el.computedStyleMap ; const opacity = styles.get 'opacity' ; console.log opacity ; // CSSUnitValue console.log opacity.value ; // 0.2 console.log opacity.unit ; // 'number However, browser support isn’t 100% uniform yet. While Chromium and Safari ship CSS Typed OM, Firefox’s native implementation is still a work in progress behind the layout.css.typed-om.enabled flag see Firefox bug 1278697 https://bugzil.la/1278697 . And even in browsers that do support Typed OM, some newer parts of the spec — like the CSSColorValue subclasses CSSRGB , CSSOKLCH , etc. — aren’t available everywhere yet. ~ enter-css-typed-om Enter css-typed-om Building a standalone CSS Typed OM polyfill has been sitting on my backlog for years — especially when seeing other projects like the partial scroll-timeline polyfill https://github.com/flackr/scroll-timeline having to roll and bundle parts of the CSS Typed OM implementation themselves just to support unit values like CSS.percent or CSS.px . However, the CSS Typed OM specification https://drafts.css-houdini.org/css-typed-om-1/ is huge , covering everything from a full CSS tokenizer and calc expression simplifier to 2D/3D matrix math and WebIDL interface rules. Writing all of that by hand was simply too big of an undertaking for a side project. But now, thanks to AI, that long-standing goal finally came within reach: meet css-typed-om https://github.com/bramus/css-typed-om-polyfill . Guided by the specification and the official Web Platform Tests, css-typed-om is a complete, standalone, and full tested polyfill that you can drop into any project. 🚀 ~ installation-and-usage Installation & Usage You can install the package from npm: npm install css-typed-om Depending on your setup, you can use css-typed-om in two ways. ~ 1. As a Global Polyfill Import the package once at the entry point of your application to automatically patch window.CSS , Element.prototype.computedStyleMap , HTMLElement.prototype.attributeStyleMap , and all CSS Typed OM classes: js import 'css-typed-om'; // Read computed styles as typed objects const element = document.querySelector '.my-element' ; const width = element.computedStyleMap .get 'width' ; console.log width.value ; // e.g., 100 console.log width.unit ; // e.g., 'px' // Set inline styles using CSS unit factories element.attributeStyleMap.set 'opacity', CSS.number 0.5 ; element.attributeStyleMap.set 'margin-top', CSS.px 20 .add CSS.em 2 ; 💁♂️ Don’t use a bundler? There’s also an IIFE build available that you can drop straight into a page via a