Skip to main content

Bug Tracker

Side navigation

#3500 closed bug (fixed)

Opened October 20, 2008 06:06PM UTC

Closed February 09, 2009 02:49PM UTC

Last modified March 14, 2012 05:43PM UTC

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:
Description

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.
Attachments (0)
Change History (9)

Changed November 20, 2008 09:31AM UTC by Quinch comment:1

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

Changed November 20, 2008 10:57PM UTC by whoop06 comment:2

Changed December 17, 2008 07:18AM UTC by morishani comment:3

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 );

Changed December 17, 2008 06:18PM UTC by whoop06 comment:4

>"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.

Changed December 18, 2008 05:48PM UTC by emartin24 comment:5

Changed January 07, 2009 09:48PM UTC by carmel_dev comment:6

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.

Changed January 20, 2009 03:49AM UTC by dmethvin comment:7

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.

Changed January 20, 2009 04:09AM UTC by dmethvin comment:8

See #3254 for more info.

Changed February 09, 2009 02:49PM UTC by john comment:9

milestone: 1.31.3.2
resolution: → fixed
status: newclosed
version: 1.2.61.3.1

Fixed in SVN rev [6186].