W3C home > Mailing lists > Public > www-style@w3.org > August 2012

Re: [css-variables] How to spec the OM for vars?

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Thu, 23 Aug 2012 22:17:47 -0700
Message-ID: <50370E7B.3090009@mit.edu>
To: Glenn Adams <glenn@skynav.com>
CC: "Tab Atkins Jr." <jackalmage@gmail.com>, www-style@w3.org
On 8/23/12 10:04 PM, Glenn Adams wrote:
> My concern on this is that it will be a rather never-ending spec
> maintenance problem, requiring new partial interfaces on a regular basis
> (i.e., every time new CSS props are introduced or changed).

Why is that particularly a problem?

> It would sure be much easier to define once in prose with a general
> purpose g/s pair.

I think getting the wording of such prose might not be trivial, for what 
it's worth.

>     Note also that if you do it that way page script won't be able to
>     hook the getters and setters for CSS properties, which is also not
>     that great.
> How much is this used? Could you give a code snippet showing such usage
> (to make sure I understand you)?

Sure.  Something like this:

   // Log and reject all attempts to set the "display" property from
   // script
   var propName = "display";
   var proto = CSS2Properties.prototype;
   var desc = Object.getOwnPropertyDescriptor(proto, propName);
   Object.defineProperty(proto, propName, {
     get: desc.get,
     set: function() {
       console.log("Attempt to set " + propName + " denied");
   // And make sure that can't be undone

Obviously you could also log and then forward to the original getter or 
setter and so forth.  People do this all the time right now with methods 
in the web platform.  Granted, for methods there's a bit less 
boilerplate needed.

Received on Friday, 24 August 2012 05:19:14 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:20 UTC