Toggle Expectations

Toggle Expectations


Hello all,
I've got a case with some unexpected behavior related to toggle; I
think it might be the root of the issues behind bugs 4681, 4960, and
5010. Basically, I think that toggle behaves in a way which is
logically correct (arguably), but not what people would expect.
The main point is that I expect toggle to be like a button that works
per element, as a switch between visible or not for this element (if I
wrote it myself using js, it would just work in terms of style.display
directly). For non-nested elements, the behavior of my version and
jquery's version would be exactly the same.
For nested elements, though, jquery checks whether the element is
visible *at all*, which means that toggling a nested element which is
within a container that is already hidden will not actually toggle the
nested element (it is already invisible, so toggle doesn't do the
expected thing).
I've posted an example file: http://www.intrepidengineer.com/toggle-behavior.html
The comments inside indicate my expectations, obviously not what
actually happens.
I know that this is relatively easy to work around, I could just write
a myToggle() extension that does what I indicated, but the presence of
so many bugs in Trac that are based on user's expectation of behavior
versus actual behavior indicates to me that this is something that
should be documented better or changed.
Thanks for all the awesome work!
Joe