IE: 'nodeType - null or not an object

I have this problem on my site in IE (6,7,8):

'nodeType is null or not an object

The error relates to the "f.nodeType" property. Basically f is undefined, so the problem precedes, but I cannot fix it.

(this line appears from the debugging of the IE developer toolbar, which throws an error) ( autocolumn.min.js line 13 expanded below for readability)

The page is at http://www.donatellabernardi.ch/drupal

 function split($putInHere,$pullOutHere,$parentColumn,height){ if($pullOutHere.children().length){ $cloneMe=$pullOutHere.children(":first"); $clone=$cloneMe.clone(true); if($clone.attr("nodeType")==1&&!$clone.hasClass("dontend")){ ^^^^^^^^^^^^^^^^^^^^^^^^^^ Chokes on $putInHere.append($clone); if($clone.is("img")&&$parentColumn.height()<height+20){ $cloneMe.remove(); }else if(!$cloneMe.hasClass("dontsplit")&&$parentColumn.height()<height+20){ $cloneMe.remove(); }else if($clone.is("img")||$cloneMe.hasClass("dontsplit")){ $clone.remove(); }else{ $clone.empty(); if(!columnize($clone,$cloneMe,$parentColumn,height)){ if($cloneMe.children().length){ split($clone,$cloneMe,$parentColumn,height); } } if($clone.get(0).childNodes.length==0){ $clone.remove(); } } } } } 
+6
jquery internet-explorer
source share
2 answers

Using the "Firebug lite" tab (you can get it here: http://getfirebug.com/firebuglite ), I could narrow down the place where the error actually throws.

It seems that the root of the problem is not in the code you extracted, but in jQuery itself.

I noticed that you are using jQuery version 1.2.6. The problem is the clone method of this version. This results in an error in this line of your published code:

 $clone=$cloneMe.clone(true); 

I could give you more detailed information exactly where the error occurs, but I do not think this will solve your problem. In any case, it would be nice to create a workaround for damaged jQuery code. I would rather try a newer version of jQuery (after a quick look I saw that the clone method is implemented differently) and see if your problem solves.

EDIT: Sorry, this is not this line

 $clone=$cloneMe.clone(true); 

but this line:

 $cache.append($(this).children().clone(true)); 

(line 42 in autocolumn.js)

+4
source share

What happens if you use $clone.get(0).nodeType === 1 ?

It is recommended that you use the strict equals === operator instead of == if the value type is known and implicit conversion is not required. The strict equality operator should also work, even if nodeType is undefined, null or "not a object"

.get(0) is probably not required. I just wanted to make sure that I was working on the Element directly, and not on a jQuery instance.

0
source share

All Articles