[css-houdini-drafts] [typed-om] Shorter dimension constructors on the CSS namespace?

tabatkins has just created a new issue for 
https://github.com/w3c/css-houdini-drafts:

== [typed-om] Shorter dimension constructors on the CSS namespace? ==
Several years ago [I left a comment about Typed OM 
stuff](https://lists.w3.org/Archives/Public/www-dom/2013OctDec/0114.html)
 wherein I suggested that the CSS namespace object could host very 
short constructors (/ factory functions) for the common dimensions.

That is, right now if you want to make a 5px length, you have to type:

```
let len = new CSSLengthValue.from(5, 'px');
```

That's long and ugly and everyone will hate us if we force them to do 
that everywhere.  My idea was to additionally allow:

```
let len = CSS.px(5);
```

Basically we'd just add functions to the `CSS` namespace object for 
all the dimensions CSS knows about. We can possibly add more for 
various functions, but it looks like we wouldn't gain much. Like, for 
transform stuff:

```
// Current
let trans = new CSSTranslation(CSS.px(5), CSS.px(10));
// Potential new?
let trans = CSS.translate(CSS.px(5), CSS.px(10));
```

It's a bit better, but not a huge win. It also suggests that we would 
need to add one for every single CSS function, and somehow deal with 
the potential places where the same function name means different 
things in different contexts. (I don't think there are any, but it's 
potentially allowed by CSS.)  I'd be fine with ignoring this, at least
 unless/until we discover in the wild that people want it. In other 
words, L2 for this stuff, but L1 for the dimensions.

Please view or discuss this issue at 
https://github.com/w3c/css-houdini-drafts/issues/320 using your GitHub
 account

Received on Tuesday, 4 October 2016 23:26:11 UTC