Ticket #2973 (closed bug: fixed)
IE6 clone(true) bug when cloning a cloned element with events
|Reported by:||futileohm||Owned by:|
I seem to have discovered an obscure bug in IE (6, I don't have a copy of 7 to test with) when using clone(true) that occurs when you clone an element with certain nested elements and events, and then clone it again. This is a regression from 1.2.3, which seems to have worked fine.
I had a hard time generalizing this bug as it seems to only happen in very specific circumstances, but I have attached a test case to demonstrate the behavior.
As far as I can tell, the most generic way to make the bug occur is to take a DOM node structured like so:
<div class='a'> <span> <span class='b'>abc</span> </span> <span> <span class='c'>abc</span> </span> </div>
and bind an event to span.b and another event to span.c. Then, clone div.a using clone(true), and then clone the clone using clone(true) again. Removing any of the surrounding span elements causes the bug to disappear, although swapping the class designation on the first set of nested span elements demonstrates the bug as well.
The specific error reported by IE is "'nodeType' is null or not an object" and occurs on the first line of the event.add function: if ( elem.nodeType == 3 || elem.nodeType == 8 ).
I tried replacing the event.add function in 1.2.3 with the event.add function from the trunk, and 1.2.3 still doesn't demonstrate the bug, leading me to believe it's elsewhere that the issue's occurring. I compared the clone functions from 1.2.3 and the trunk and didn't see any major changes that may have caused this sort of an issue, but at that point I was out of my league.
I'm not sure that this is a major regression, but it's a regression nonetheless, so I would imagine it should probably be fixed to maintain backwards compatibility.