From: Robin B. <ro...@kn...> - 2001-09-28 15:21:08
|
On Friday 28 September 2001 16:02, Antoine Quint wrote: > The CSSStyleDeclaration interface could be improved. You bet. > First off, we need a method to give a string access to this interface's > methods. Like > > var string = 'fill: red; opacity: 1'; > var CSSString = doc.createCSSStyleDeclaration(string); We need create* (preferably on CSSImplementation, or on specific Factory interfaces) for everything (SAC has those). Your above example could be a shortcut, but I would much prefer: // RGBCOLOR and REAL are constants defined in SAC var CSSDecl = factory.createCSSStyleDeclaration(); var redLU = factory.createCSSLexicalUnit(RGBCOLOR, 'red'); var CSSDecl.addProperty( factory.createCSSPropertyValue('fill', redLU) ); var opaLU = factory.createCSSLexicalUnit(REAL, 1); var CSSDecl.addProperty( factory.createCSSPropertyValue('opacity',opaLU) ); It's more verbose but it means that you're now manipulating PropertyValue objects, which in turn means that they are what will be returned by CSSDecl.item(i), and that would have getName, getType, getValue, and a variety of things from http://search.cpan.org/doc/RBERJON/CSS-SAC-0.03/SAC/LexicalUnit.pm I prefer verbosity to uselessness. I guess I won't get much argument here. > Right now, I have to use a non-appended node to which I > createAttribute('style', string). Then I get my CSSString through > getStyle and removeAttribute('style'). This is just annoying. Yeah I know. It's not only annoying, it's a filthy dirty hack (curtesy of yours truly). I'm afraid there's no better solution in CSS DOM level 2. > That's it. Oh, I'm not so sure that's it. You'll probably hit a few other walls along the way :-) -- _______________________________________________________________________ Robin Berjon <ro...@kn...> -- CTO k n o w s c a p e : // venture knowledge agency www.knowscape.com ----------------------------------------------------------------------- "Oh no not again !" said the bowl of petunias |