Last Comment Bug 45424 - implement getOverrideStyle()
: implement getOverrideStyle()
: dom2, helpwanted
Product: Core
Classification: Components
Component: DOM: CSS Object Model (show other bugs)
: Trunk
: All All
: P3 normal with 17 votes (vote)
: ---
Assigned To: Pete Collins (MDG)
: Andrew Overholt [:overholt]
: 62695 (view as bug list)
Depends on:
  Show dependency treegraph
Reported: 2000-07-13 14:38 PDT by Pete Collins (MDG)
Modified: 2014-07-08 15:50 PDT (History)
27 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Description Pete Collins (MDG) 2000-07-13 14:38:26 PDT
I need some way to dynamically set alternative pseudo styles 

ex: hover, active etc . . . 

the style property for xul element objects i don't think will give me this.
It just when implemented, give me the "normal" style rules. Which i don't need
right now.

This is a blocker for the Theme Builder.

Any ideas?


Comment 1 Chris Waterson 2000-07-13 14:50:59 PDT
Comment 2 pete collins 2000-07-13 16:15:08 PDT
Here is a better discription:

I was asked to file this bug. I am just not explaining what i need properly.


Comment 3 David Baron :dbaron: ⌚️UTC-10 2000-07-13 16:37:53 PDT
How do you want to set them?  If the element has an ID or a class (which you 
can give it dynamically) you could dynamically add a rule to a stylesheet.  I 
think that's the only way right now, and the only way within any standards.
Comment 4 Johnny Stenback (:jst, 2000-07-13 16:55:41 PDT
Pete, answering your questions in bug 7639: Yes, this can be done with
document.getOverrideStyle(), look at

with getOverrideStyle() you can access the override style, pseudo or not, for
any element, what you get is a CSSStyleDeclaration, i.e. same as you get through so yes, you can both set and get values from the override style.
Please note that the delcaration you get from getOverrideStyle() is for one
element only, i.e. if you have other elements with the same name their style
should remain uneffected by any changes made to the override style...

Waterson, I think this is a valid bug, but this should most likely be futured...
Comment 5 pete collins 2000-07-13 17:20:34 PDT
Yea, thanks Johnny, i was reading it over.
getOverrideStyle(in Element elt,in DOMString pseudoElt);

I would call it like this:
var doc = document;
var foo = doc.getElementById('someID');
doc.getOverrideStyle(foo, 'hover');


doc.getOverrideStyle(foo, 'active');

And then to set it, i would do:

doc.getOverrideStyle(foo, 'hover') = "color: red;"

If this is correct, then yes this is EXACTLY what i need. 

I am assumeing that this is a top level dom call similar to getElementByID().

I am willing to help out any way i can to get this implemented.

Comment 6 pete collins 2000-07-13 18:27:23 PDT
Tim Hill posted the correct usage in the layout ng:

styledecl = document.getOverrideStyle(element, "hover");
styledecl.setProperty("background-color", "black", "");
styledecl.setProperty("color", "white", "");

This is definitely what i'm looking for.

Comment 7 Pete Collins (MDG) 2000-07-14 07:04:46 PDT
Yes, here is a test case from xul.

  id        = "stop-button"
  class     = "button-toolbar-1 top"
  onclick   = "var foo = document.getOverrideStyle(this,'hover');"/>


JavaScript error:
 line 0: uncaught exception: [Exception... "Object is of wrong type"  code:
"1002" nsresult: "0x805303ea (NS_ERROR_DOM_WRONG_TYPE_ERR)"  location:

Comment 8 Pete Collins (MDG) 2000-07-14 07:26:45 PDT
It's listed here among the document class methods.

Comment 9 Pete Collins (MDG) 2000-08-29 10:21:33 PDT
Hey Chris, is this in any way possible to implement from JS?

If so i would definately have a go at it. 

If the interfaces that contain all of the css style rules etc . . are scriptable
then you never know what could happen.

Comment 10 Paul Wyskoczka 2000-08-30 09:52:44 PDT
Updating QA Contact to
Comment 11 Todd Pringle 2001-01-11 11:22:05 PST
Joe -

This is preventing Alphanumerica from being able to implement the import theme
functionality we wanted in the themebuilder tool.  Right now the modern theme is
hardcoded in and is the only starting point.  Any ideas?
Comment 12 Joe Hewitt (gone) 2001-01-11 12:19:42 PST
Todd, this is just one of the many DOM Level 2 things that aren't implemented 
but would be nice to have... you'd probably have to bug trudelle to find 
someone to implement it if they have the time, which is probably not likely at 
the moment given the current priorities.
Comment 13 Todd Pringle 2001-01-16 17:50:43 PST
Peter (Trudelle) - is this even a possibility for 6.5?  Is there anyone outside
of your group that could possibly implement it?
Comment 14 hangas 2001-01-17 17:41:17 PST
Themes Triage Team changing to DOM Level 2
Comment 15 Johnny Stenback (:jst, 2001-02-14 16:49:46 PST
*** Bug 62695 has been marked as a duplicate of this bug. ***
Comment 16 Hixie (not reading bugmail) 2001-02-22 22:54:01 PST
Taking QA Contact on all open or unverified DOM Style bugs...
Comment 17 Peter Trudelle 2001-02-27 18:45:58 PST
Todd, Joe - Would love to help out, but we are swamped. (& please note that DOM
level 2 is not our area anyway)
Comment 18 Pete Collins (MDG) 2001-02-28 05:28:53 PST
I started looking into this and Johnny S is helping me out.
I just don't have any time. Arg!

I really hope to resume in a week or two.
There is only so much i can do in that hour ride on the train home. ;-)


Comment 19 Hixie (not reading bugmail) 2001-04-26 17:08:40 PDT
Nominating this bug for nsbeta1 on behalf of
Comment 20 Hixie (not reading bugmail) 2001-05-03 18:44:49 PDT
Removing nsbeta1 nomination -- there was a misunderstanding and some "approved
out features" were nominated by mistake! Sorry!
Comment 21 Pete Collins (MDG) 2001-07-23 08:54:46 PDT
assigning to myself
Comment 22 Girish Manwani 2001-07-25 17:02:45 PDT
pete are u working on this implementation ?? i cold not find any implementation
of nsDOMDocumentStyle also and hence nsDOMDocumentCSS has not been implement. I
would like to help in getting this working.. let me know if you need help
Comment 23 Pete Collins (MDG) 2001-07-25 17:34:17 PDT
I have this on my bug list. I will let you know when i get to it.


Comment 24 Asa Dotzler [:asa] 2001-12-03 10:53:04 PST
Bugs targeted at mozilla1.0 without the mozilla1.0 keyword moved to mozilla1.0.1 
(you can query for this string to delete spam or retrieve the list of bugs I've 
Comment 25 LPB 2005-01-04 12:42:02 PST
In Seamonkey/Javascript, please implement the DocumentCSS interface on
XMLDocument or Window so it is possible to programmatically *set* style on
Element nodes. It is currently possible to *get* style on such nodes using
getComputedStyle from the ViewCSS interface (implemented by Window).
Comment 26 Aurélien Maille 2005-01-29 08:22:34 PST
Does getOverrideStyle() should accept pseudo-classes (hover,
activates...) in second argument ?

DOM CSS say (for getComputedStyle() and getOverrideStyle()):
"pseudoElt of type DOMString
    The pseudo-element or null if none."
Comment 27 Daniel Holbert [:dholbert] 2008-10-06 18:15:18 PDT
FWIW, this feature -- getOverrideStyle() -- is probably needed to support SVG/SMIL Animation of CSS properties.

Quoting the SMIL Animation Specification:

"When animation is applied to CSS properties of a particular element, the base value to be animated is read using the (readonly) getComputedStyle() method on that element. The values produced by the animation are written into an override stylesheet for that element, which may be obtained using the getOverrideStyle() method. These new values then affect the cascade and are reflected in a new computed value (and thus, modified presentation)."

Also, FWIW -- the above paragraph is a bit vague on whether or not a change to getOverrideStyle() should modify the output of getComputedStyle().  But per discussion on www-style ([2], [3]) it sounds like it *is* supposed to modify the computed style.

Comment 28 Daniel Holbert [:dholbert] 2012-02-14 15:51:10 PST
(In reply to Daniel Holbert [:dholbert] from comment #27)
> FWIW, this feature -- getOverrideStyle() -- is probably needed to support
> SVG/SMIL Animation of CSS properties.

(Just to follow up on this -- we didn't end up needing this for SMIL -- we ended up going with a custom SMIL-specific override stylesheet that's not exposed via the DOM at all.  For reference, see bug 474049 comment 10, first bullet-point.)

Note You need to log in before you can comment on or make changes to this bug.