Sébastien Grosjean - ZenCocoon wrote:
> T.J.,
> Well I thought software development to put higher challenges ;-)
> The problem using Element.addClassName is that inline styles still
> overwrite it.
> If that was only for this $(element).style.cssText = ''; would do the
> trick but there's more.
> Such feature can also allow easier morphing effects (or other
> variations).
> For instance, that would allow you to morph an element from one class
> name properties to an other class name properties.
> It's basically allow you to manage animation from CSS, it makes
> element styling a bit more flexible and brings animations possibility
> a step forward I think.
Interesting idea.  The thing is, you are thinking of a CSS class name as 
being a collection of styles.  But a CSS class name is just a string; a 
CSS selector is a collection of styles.  In order to find out what 
styles cascade to a certain element is quite complex (think firebug or 
Dean Edwards IE8.js).  To do what you're saying, you would have to find 
out what styles would cascade to the element if it had a certain CSS 
class name /and/ the CSS rules overrode inline properties.

A shortcut way, I suppose, would be to remove all the inline styles, 
apply the CSS class name, look at the computed styles, then re-apply the 
inline styles that don't conflict.  Unfortunately that would probably 
produce a flicker.

You can probably get your desired API by defining an object with a group 
of styles:

var beginStyle = {
  color: '#ff0000',
  border: '2px solid red',
  fontSize: '16px'
var endStyle = {
  color: '#000000',
  border: 'none',
  fontSize: '12px'


> P.S. : As far as I know, such concept is already used by at least
> jQuery and MooTools.
Perhaps you mean those libraries have that functionality in plugins, but 
I'm skeptical that they use a CSS Rule parser in the core library.  I 
use jQuery and haven't seen such behavior.  Do you have a source?  What 
are their approaches and APIs?

- Ken Snyder

You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 

Reply via email to