Re: [css-variables] CSSVariablesMap interface doubts

On Fri, Jun 14, 2013 at 5:58 PM, Claudio Saavedra <csaavedra@igalia.com> wrote:
> Hi,
>
> I'm implementing the CSSVariablesMap interface in WK. I have a doubt
> regarding access to the elements in the map. Previously, if my memory is
> not failing me, for a block with a variable declared like
>
> div: {
>   var-foo: 10px;
> }
>
> it was specified that one could access it also as a property of the
> interface, directly:
>
> Code                      Value
> el.style.var.get("foo")   10px
> el.style.var.foo          10px
>
> Is this direct access still allowed as of the latest specifications? I
> think it's not entirely clear.
>
> If the answer is yes, what should the behavior be, shall there be any
> variable with a name that conflicts with the methods in the interface?
>
> div {
>    var-has: 16px;
> }
>
> Code                      Value
> el.style.var.has("has")     ?
> el.style.var.has            ?

Yes, previously the latter was allowed.  TC39, the committee defining
JS, isn't a fan of those kinds of interfaces, though.  For example, if
you added "CSSVariablesMap.prototype.foo = 'bar';", then reading
"el.style.var.foo" would return "bar", even though there is *not* a
var-foo property on the style rule!

Instead, I recently opened up some discussion with TC39 about using
the JS Map interface more directly, because that avoids these
problems.  (And, as more generic Map-related functions show up,
they'll work on the var map as well.)

> Also, and slightly unrelated, in 4.2 there's a text "map tuples" with a
> hyperlink that seems to be pointing to the wrong place
> (http://dev.w3.org/2006/webapi/WebIDL/#REPLACE-ME).
>
> Lastly, I seem not to be able to find where MapClass, the extended
> attribute used in the interface definition, is defined. Would someone
> care to point me out to it?

WebIDL hasn't been updated with that yet.  I went ahead and put in
some example IDL in Variables, which heycam (the WebIDL editor) will
use for inspiration when he gets time to put it in, sometime next
week.  When he does so, I'll update to whatever he ends up with.

~TJ

Received on Friday, 14 June 2013 16:19:56 UTC