Re: [cssom] Proposing a getDefaultComputedStyle method

On Fri, 12 Oct 2012 20:36:33 +0200, Boris Zbarsky <> wrote:

> Proposal: a getDefaultComputedStyle method that acts just like  
> getComputedStyle but returns what the style would be if it were not for  
> author rules.
> Rationale: jQuery has hacks to try to figure out default styles,  
> involving creation of subframes and so forth.  These hacks are very  
> fragile.  There's got to be a better way for libraries to do this sort  
> of thing.
> IDL:
>      CSSStyleDeclaration
>        getDefaultComputedStyle(Element elt,
>                                optional DOMString pseudoElt);
> Behavior is just like getComputedStyle except:
> 1) Ignores all author-level sheets, transitions, animations,
>     override stylesheets.
> 2) Never returns used styles, only computed ones (just like
>     getComputedStyle would for a display:none element).
> My implementation at the moment also ignores presentational hints, but  
> I'm open to changing that if people think it would be better to include  
> them.


I think presentational hints are supposed to be like author-level styles,  
so I didn't include them.

> See also for the  
> implementation and  
> for the jQuery issues that prompted this suggestion.  The jQuery folks  
> sound like they would really like something like this, for what it's  
> worth.
> -Boris

Simon Pieters
Opera Software

Received on Wednesday, 24 April 2013 11:51:36 UTC