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

RE: [cssom] Methods instead of attributes for usedStyle et al

From: François REMY <francois.remy.dev@outlook.com>
Date: Tue, 13 Aug 2013 20:02:53 +0200
Message-ID: <DUB120-W26C23CB9968A1B43BA4046A5440@phx.gbl>
To: Simon Pieters <simonp@opera.com>, "www-style@w3.org" <www-style@w3.org>
> While trying to use WebIDL's new [SameObject] and [NewObject] extended
> attributes where applicable in CSSOM [1], I noticed that the GetStyleUtils
> members return new objects each time but doing so is discouraged for
> attributes [2]. I don't think it makes sense for these to return the same
> object each time since that would mean having to keep the object live
> which is probably quite expensive.

Why? You don't actually have to "keep the object live", it's exactly similar to getComputedStyle(element) works (or element.currentStyle in IE, for what it's worth): the object is a sort of proxy and when you ask for a propery it returns from cache the value is up-to-date or modify the cache if it's not (or not anymore). It doesn't cost more than calling the getSomeStyle() function again and again every time. 

In fact, I would argue it's better because the issue if you outputs a static object is that you've to compute the value of every property straight when calling the function, while you can do so lazily per-property on demand with a live object.

Thoughts? 		 	   		  
Received on Tuesday, 13 August 2013 18:03:24 UTC

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