[whatwg] New method for obtaining a CSS property
Tab Atkins Jr.
jackalmage at gmail.com
Wed Jan 26 23:59:10 PST 2011
On Wed, Jan 26, 2011 at 10:23 PM, Brett Zamir <brettz9 at yahoo.com> wrote:
> 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
> does not want to have to change her code every time 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 code improperly. So the
> 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'
> the fashion desired by the developer.
> Yes, there are CSS transitions, or maybe SVG, but this is for cases where
> 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.
Given a selector, multiple declaration blocks could match, and within
a single declaration block, multiple copies of the property can match.
You could get any number of values back from a call like that, and
there's no guarantee that the value you get is worth anything, because
a property from some other declaration block with a different selector
could be winning instead.
It seems that your problem is that you want a way to declare a certain
it in either realm without having to care about it in the other.
This can be solved cleanly and easily with CSS Variables. The CSS
Working Group has tried several times to agree on how such a thing
should work, so far without success, but Chrome is trying again now.
Check out my blog post on the subject:
More information about the whatwg