Bug Tracker

Opened 9 years ago

Closed 8 years ago

Last modified 5 years ago

#3500 closed bug (fixed)

IE clone( true ) error on recloning

Reported by: whoop06 Owned by:
Priority: major Milestone: 1.3.2
Component: core Version: 1.3.1
Keywords: clone ie7 ie6 Cc:
Blocked by: Blocking:


IE7 and IE6 give the error "'nodeType' is null or not an object" when attempting to clone an object that is itself a clone.

This error only occurs when the object has grandchildren and events attached to the object or its descendants.

An example can be found at http://kitchen.net-perspective.com/ie-clone-bug.html

Commenting out the IE specific block in the clone function (lines 278

  • 291 in 1.2.6 core) alleviates the bug.

Change History (9)

comment:1 Changed 8 years ago by Quinch

Is there any plans for this? It's just bit me with the simpleModal plugin.

comment:3 Changed 8 years ago by morishani

Happened to me too, And then I thought, Why not cloning the first element instead the last?

The fix for the script (Not jQuery, but your example) is changing the row :

				$( '.test:last' ).clone( true );

To :

				$( '.test:first' ).clone( true );

comment:4 Changed 8 years ago by whoop06

"Why not cloning the first element instead the last?"

Because the point isn't to find a workaround for the simplified test case, but rather to illustrate the existence of a bug.

comment:6 Changed 8 years ago by carmel_dev

I have received this error for several clone circumstances. The underlying issue appears to be that the event re-attachment code for the cloned objects requires that the position of cloned elements be identical to the position of the original elements. (The event attachment code executes the each function on the original elements and references clone[i], where i is the position of the original element.)

I discovered that the clean function sometimes removes elements. In these cases, clone[i] is undefined where i >= clone.length but i < this.find("*").andSelf().length -- then undefined is passed to the jQuery.event.add function, and elem.nodeType in the add function throws the error.

To determine the number of dropped elements when you receive the error, insert the following line of code just after clone is initialized:

  var diff = this.find("*").andSelf().length - clone.length;

I have not been able to pinpoint the area of the clean function that is removing these elements; I am hoping that someone will take this line of thought with the provided example and discover the root cause.

comment:7 Changed 8 years ago by dmethvin

Funny you should mention that, carmel_dev, I was looking at the clone() code and noticed that it depended on the node counts being identical as well. So I went looking for tickets that might be related to the two being out of sync.

Do you have some test cases that demonstrate the problem? I was thinking it might happen, for example, when adjacent text nodes are serialized into a string and then come back out as a single text node, but I couldn't reproduce a simple case.

comment:8 Changed 8 years ago by dmethvin

See #3254 for more info.

comment:9 Changed 8 years ago by john

Resolution: fixed
Status: newclosed

Fixed in SVN rev [6186].

Note: See TracTickets for help on using tickets.