W3C home > Mailing lists > Public > www-style@w3.org > October 2012

[cssom] Proposing a getDefaultComputedStyle method

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Fri, 12 Oct 2012 14:36:33 -0400
Message-ID: <50786331.6080905@mit.edu>
To: www-style list <www-style@w3.org>
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.


       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 

See also https://bugzilla.mozilla.org/show_bug.cgi?id=800983 for the 
implementation and https://bugzilla.mozilla.org/show_bug.cgi?id=797029 
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.

Received on Friday, 12 October 2012 18:37:02 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 11 February 2015 12:35:17 UTC