From: Robin B. <ro...@kn...> - 2001-09-18 17:23:05
|
On Tuesday 18 September 2001 18:51, Antoine Quint wrote: > In the gradients module, there is a function called at init that looks > up the DOM tree for the shapes filled with the gradients that are > i:gradient enabled. So what I do is look through > doc.getElementsByTagName('*') and I check each element's "fill" property > to see if it refers to the specified gradient. This is extremely expensive, are you sure there's no better way ? Wouldn't you be able to specify the targets on the gradient or something like that ? <i:gradient> <i:target xlink:href='#foo'> <i:target xlink:href='#bar'> </i:gradient> > Problem is that before I > read the "fill" property I need to check if that particular element > allows for the Style interface (getStyle()) to be called. > > Anybody knows how to do this? I'm presently looking into ways of making E262 really OO, and it's not looking nice (it's even less OO than Java !). You might try element.prototype.hasOwnProperty('style'), that should normally tell you whether your object has a property called style, which is needed by getStyle(). However I wouldn't be surprised if it didn't work. Another option is to do the tricks people do in browsers (eval'ing to see if it works, testing the returned value to be an object, etc). Also note that it is possible -- though marginal -- that an element would have a getStyle() method that is not what you expect (this could happen with embedded XHTML for instance). That could have nasty side-effects (as most abuses of polymorphism would). -- _______________________________________________________________________ Robin Berjon <ro...@kn...> -- CTO k n o w s c a p e : // venture knowledge agency www.knowscape.com ----------------------------------------------------------------------- An eye for an eye will make the whole world blind. -- Mahatma Gandhi |