[jQuery] jquery "1st space" bug while working with classes
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=koi8-r">
<META content="MSHTML 6.00.2900.2180" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>i need some script that works with elements
classNames, i used heavily jquery's addClass, removeClass, toggleClass to get
tricky combinations of classes, and that's what i discovered:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>in Opera 9 strange space appears in the beginning
of complex classNames...</FONT></DIV>
<DIV><FONT face=Arial size=2>for example:</FONT></DIV>
<DIV><FONT face=Arial size=2>while in FF elements className after series of
events states: "white active"</FONT></DIV>
<DIV><FONT face=Arial size=2>in Opera the same element after same events has
classNames: " active white"</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>so in Opera this styles won't apply for this
element (while FF behaves as expected):</FONT></DIV>
<DIV><FONT face=Arial size=2>td.white.active{</FONT></DIV>
<DIV><FONT face=Arial size=2> background:#FFF;</FONT></DIV>
<DIV><FONT face=Arial size=2> border-color:#F00;</FONT></DIV>
<DIV><FONT face=Arial size=2>}</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>right now for temporarily solution i changed the
jquery lib source code:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>jQuery.className = {<BR> add:
function(o,c){<BR> if (jQuery.hasWord(o,c))
return;<BR> o.className += ( o.className ? " " : "" ) +
c;<BR> // ltrim:<BR> while (o.className.substring(0,1) ==
' '){<BR> o.className = o.className.substring(1,
o.className.length);<BR> }<BR> },<BR> remove:
function(o,c){<BR> o.className = !c ? ""
:<BR> o.className.replace(<BR> new
RegExp("(^|\\s*\\b[^-])"+c+"($|\\b(?=[^-]))", "g"), "");<BR> //
ltrim:<BR> while (o.className.substring(0,1) == '
'){<BR> o.className = o.className.substring(1,
o.className.length);<BR> }<BR> }<BR>};</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>but maybe, you will take it into consideration, do
some cross-browser tests andremove this bug...</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>P.S. - i'm not sure, but i guess the same bug
appears in IE either</FONT></DIV></BODY></HTML>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/