View Full Version : Style object

03-17-2006, 02:08 PM
I wish to construct a tree from a styleSheet object.
Each node will be a selector which will have rules as child nodes.

Do I have to iterate through each of the rules from the styleSheet object and create a compare the selector name with the previous in order to do this? Are there methods or properties for navigating a styleSheet object like an element? Like, being able to just traverse each selector and fetch the rules for each?

03-17-2006, 03:06 PM
Well, it's a tree already. Iew uses it's own object model, Opera doesn't and won't support programmatical access to style sheets for op9 and earlier, moz uses a partial (pretty full actually, but wrong in some details) implementation of the W3C object model, and I've not got any idea about saf.

The iew model:

The W3C model:
In which you're mostly interested in this part:

Basically, for what you want to do, you just need to know a few differences between the object models. The iew model uses oStyleSheet.rules and the W3C model uses oStyleSheet.cssRules for the rule list. Both use oRule.selectorText for accessing the selector part of the rule set.

They differ in several other parts though, and sometimes the documentation isn't that good.

03-17-2006, 05:22 PM
They differ in several other parts though, and sometimes the documentation isn't that good.

Unfortunately, yes... In a similar attempt I had to check step by step every assignment, method. And, yes, I have sensed the Opera's low response on it... If you meet some further problems on your try ,Mhtml, post them here, maybe some of us has already bypassed them :thumbsup:

03-17-2006, 09:40 PM
More information: http://www.quirksmode.org/dom/changess.html

03-18-2006, 02:08 AM
Sweet, thanks guys. I'm not too worried about cross browser compatability. I'm just writing a few tools to speed up my development times so it really only has to run on FF to start with till I port them to C++.