Re: What exactly is the replacement for getDefaultComputedStyle?

I advocated for having this information as well about a year or so ago. 


What ended up happening is Tab said the CSS3 display module will fix this by making "display" a shorthand so that "none" could be specified without obliterating the display-inside and display-outside properties. 




That spec hasn't really moved at all, and devs, specifically us in jQuery world, still feel the pain of needing this hack every day.




The reasons given to not pursue spec cing getDefaultComputedStyle at the time seemed to be (and forgive the paraphrasing):




1. It seems hard for browsers to accomplish this, having to do two cascades. (Although the irony of it being already implemented in FF makes this particularly sad).




2. "display" is broken, and getDefaultComputedStyle seems like a hack to fix that one property. (Although I'm not personally convinced how hacky it is. Knowing how a browser renders a property by default seems useful and straightforward). 




3. The display problem "is a problem of the past, focus on the future" (even though the fix, CSS3 display, has basically stagnated with it's own non-insignificant amount of use cases to consider. Not to mention that it relies on the developer to "do the right thing" and use the new display values rather than giving jQuery the power to just do the right thing easily). 
—
Sent from Mailbox

On Tue, Sep 2, 2014 at 5:10 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:

> At one point we agreed to add Element.getDefaultComputedStyle to CSSOM 
> to address the "what is the default (user+ua) value for this element for 
> a given CSS property?" use case.
> It looks like it's been removed from CSSOM at some point, but I see 
> nothing replacing it.  Certainly none of the things on 
> http://dev.w3.org/csswg/cssom/#getstyleutils cover this use case.  Am I 
> just missing something?
> The lack of such an API is causing libraries like jQuery to rely on 
> weird display:none iframe hacks in an attempt to gather this sort of 
> information.  And even with those hacks, if user/UA stylesheets have 
> media query dependent styles there's no way for them to get correct answers.
> -Boris

Received on Tuesday, 2 September 2014 22:58:07 UTC