Questions / best practices regarding toggle patch for ticket #5274

Questions / best practices regarding toggle patch for ticket #5274

I was just reviewing an issue I submitted when multiple toggle event
handlers are bound to the same element. The issue is that the toggle
functionality uses an expando this.lastToggle to keep track of the
current position: but it gets messed up with multiple handlers. The
post here (mostly me waffling)
http://groups.google.com/group/jquery-dev/browse_thread/thread/2af6983e9ef3848/badf740f841a6dc4
details the issue.
I was going over the possible patch I submitted (http://dev.jquery.com/
ticket/5274) and was wondering if it's acceptable, and if not, what a
better approach would be. The patch replaced this:
this.lastToggle = ( this.lastToggle || 0 ) % i;
...
return args[ this.lastToggle++ ].apply( this, arguments ) || false;
With this:
var lastToggle = ( $(this).data( 'lastToggle' + fn.guid ) || 0 ) % i;
$(this).data( 'lastToggle' + fn.guid, lastToggle + 1 );
...
return args[ lastToggle ].apply( this, arguments ) || false;
My questions are: is using 'lastToggle' + fn.guid as a data key
acceptable? It kind of looks a bit funky... and would it be preferable
to store $(this).data in a variable reference to prevent doing the $
(this) selector twice (at the cost, I think, of readability)?
Thanks!
Earle
--