toggle() does not work as I would expect when the actual initial
display value is connected to a CSS rule rather than directly to the
element's style. For instance, if you define a particular element in
HTML as:
<div id="foo" class="hidden">
where hidden is defined as
.hidden { display: none;}
toggle won't know that the element is hidden, because it checks for
whether "elem.style.display" is "none", rather than, say, calling
getStyle(elem, 'display"), which would return the actual effective
display value.
The actual effect of this is that for the first call to toggle, for an
element hidden via CSS as above, toggle thinks the element is visible
and disappears it. Thereafter, elem.style has the information locally
and toggle works as you'd want it to.
To me this seems like a bug, but maybe someone is aware of a use case
for the existing functionality. I'm not, so I append a diff with the
trivial fix.
Cheers,
js
Index: Visual.js
===================================================================
--- Visual.js (revision 1270)
+++ Visual.js (working copy)
@@ -459,7 +459,7 @@
queue: {position: 'end', scope: (element.id || 'global'),
limit: 1}
}, options || {});
var v = MochiKit.Visual;
- v[element.style.display != 'none' ?
+ v[MochiKit.Style.getStyle(element, 'display') != 'none' ?
v.PAIRS[effect][1] : v.PAIRS[effect][0]](element, options);
};
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---