W3C home > Mailing lists > Public > www-dom@w3.org > July to September 1999

DOM2 CSS Implementation advice requested

From: David Schweinsberg <david@steadystate.co.uk>
Date: Mon, 6 Sep 1999 23:07:22 +0100
To: "DOM Mailing List" <www-dom@w3.org>
Message-ID: <LOBBIFPFKJEMLGNLKNMCCEBICBAA.david@steadystate.co.uk>
Hi

I need to know what to do in the following situations.  This code snippet is
in Java.

...
// Item n is known to be a StyleRule
CSSStyleRule sr = rules.item( n );

// Now, let's make it a Media Rule
sr.setCssText( "@media print { H1 { page-break-after: avoid } }" );

// Ouch!  "sr" is of type CSSStyleRule!
String sel = sr.getSelectorText();
...

What I could do is what I did with CSSValue - support both CSSPrimitiveValue
& CSSValueList interfaces - so one can set the "cssText" to a list or a
single value, and it becomes the appropriate type.  This still leaves an
ugly problem of incorrect type references.

I hesitate to do this for rules - it would be a real mess.  I was
considering a design pattern like "State", but I don't know.

Currently, I'm throwing an exception if "cssText" is set to a differing rule
type.  People's thoughts please!

David Schweinsberg
Steady State Software Ltd.
http://www.steadystate.com/
Received on Monday, 6 September 1999 18:07:01 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:46 GMT