6

I'm having this issue on my website in IE (6,7,8):

‘nodeType’ is null or not an object

The error refers to "f.nodeType" property. Basically f is undefined, so the issue is before, but I cannot fix it.

(from IE developer toolbar debug it appears to be this line that is throwing the error) (autocolumn.min.js line 13 expanded below for readability)

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(); } } } } } 
13
  • @scunliffe. Thanks for editing. How did you expand Javascript ? are you using a specific software or you did it manually ? thanks Commented Jun 11, 2010 at 13:01
  • 1
    I don't know jquery well enough to know if this: $clone.attr("nodeType") should be $clone.nodeType- but nodeType is not an attr in ordinary javascript/dom.. Commented Jun 11, 2010 at 13:11
  • 1
    kennebec: jQuery's attr method doesn't always deal with attributes. Sometimes it deals with properties, and sometimes it deals with attributes, depending on the property/attribute being accessed. Getting to the heart of exactly what it is supposed to do seems to have been beyond whoever documented it in the jQuery docs. Commented Jun 11, 2010 at 13:21
  • @Patrick - no problem on the edits, as for the formatting I have a tool for that ;-) but all it does is asks Firefox for the string value of the function... and it auto formats it. Commented Jun 11, 2010 at 13:41
  • Update: $clone = $cloneMe.clone(true); the cloning function is causing the issue (probably because I'm not using the most recent version of jQuery (but I cannot upgrade, since I'm using Drupal) Commented Jun 12, 2010 at 9:11

2 Answers 2

4

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

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

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

$clone=$cloneMe.clone(true); 

I could give you more details, where exactly the error happens, but I don't think that this will solve your problem. Anyway it's not a good idea to build a workaround for the flawed jQuery-code. I'd rather recommend to try a more recent version of jQuery (after a quick glance I saw that there the clone-method is implemented differently) and have a look if that solves your problem.

EDIT: Sorry, it's not this line

$clone=$cloneMe.clone(true); 

but this line:

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

(line 42 in the autocolumn.js)

Sign up to request clarification or add additional context in comments.

1 Comment

ok thanks, the issue is that I cannot upgrade jQuery because Drupal doesn't support it. Should I consider to use 2 jquery versions (I not this is not efficient solution, but it might be a reasonable one).
0

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

It's recommended to use the strict equals operator === instead of ==, if the type of the value is known and no implicit conversion is needed. The strict equals operator should also work even if nodeType would be undefined, null or "not an object"

.get(0) probably is not necessary. I just wanted to make sure to work on the Element directly and not over the jQuery-Instance.

1 Comment

hi, it is the same, same error message. Anyway it works then, what I want to remove is the annoying error message in IE

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.