[whatwg] New method for obtaining a CSS property
bzbarsky at MIT.EDU
Thu Jan 27 10:19:52 PST 2011
On 1/27/11 1:23 AM, Brett Zamir wrote:
> I'll give a more concrete example, but I did state the problem:
> separation of concerns, and the data I want, getting a CSS property for
> a given selector.
"selectors" don't have properties. Elements have properties, and
declarations have properties. "selectors" are a mechanism for tying
rulesets to declarations.
> For example, we want the designer guy to be able to freely change the
> colors in the stylesheet for indicating say a successful transition
> (green), an error (red), or waiting (yellow) for an Ajax request. The
> designer has a new whim about making the error color a darker or lighter
> red, and the designer is afraid of getting balled out for altering her
> the "background-color" property to get whatever the current error color
> is and then indicates to an animation script that "darkred" should be
> the final background color of the button after the transition. The
> retrieval might look something like:
> document.getCSSPropertyValue(".error", "background-color"); // 'darkred'
You can do that right now using getComputedStyle, with a bit more code,
> Or, for canvas specifically. You draw an animated "Hello" and want the
> designer to be able to choose the fill color. You want to be able to
> query the stylesheet easily to get the styling info.
Or just set a class on your canvas and let styles apply to it as normal?
More information about the whatwg