Skip to main content

Bug Tracker

Side navigation

#9479 closed bug (worksforme)

Opened June 01, 2011 08:12AM UTC

Closed June 03, 2011 09:53PM UTC

Last modified June 07, 2011 07:09AM UTC

o is null

Reported by: anonymous Owned by: anonymous
Priority: low Milestone:
Component: effects Version: 1.6.1
Keywords: Cc:
Blocked by: Blocking:

in firefox I obtain always "o is null" when using toggle()

Attachments (0)
Change History (5)

Changed June 01, 2011 01:11PM UTC by addyosmani comment:1

component: unfiledeffects
owner: → anonymous
priority: undecidedlow
status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a reduced jsFiddle test case to help us assess your ticket!

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: Open the link and click to "Fork" in the top menu.

Changed June 03, 2011 01:45PM UTC by anonymous comment:2

status: pendingnew


I found that this error "o is null" appears just with 1.6.1 while if I use 1.5.1 I obtain a "JQuery is not defined" on the jquery UI code which is loaded correctly after JQuery.

I am using Firefox 4.0.1

My page is XHTML 1.0 Transitional (validated) and I am pretty sure that I had no problems using HTML 4.0 with JQuery.

Now I upgraded to XHTML 1.0 and JQuery doesn't work anymore even if I downgrade to older versions.

My code is almost stupid as first rows are just calling a toggle() function on a div.

So the same page with different jquery versions provides different errors.

I can't help more at the moment.

Best regards


Changed June 03, 2011 09:53PM UTC by addyosmani comment:3

resolution: → worksforme
status: newclosed

Using the information you've provided, I've put together a test case using XHTML 1.0 transitional, jQuery edge (1.6.1-post, our current in-development version) and a basic toggle() example here Running this in Firefox 4.01, Chrome and the latest version of the other popular browsers, everything appears to work fine without error messages being output.

With this in mind, I'm tempted to think that the problem you're experiencing may be related to your code or what you're trying to do. If you need further assistance debugging the issue, please feel free to speak to a community member about it in our forums or on IRC/freenode under the #jquery channel. Should this result in some more information on the cause of the issue, we'll be happy to re-evaluate.

Changed June 06, 2011 09:47AM UTC by anonymous comment:4

Thanks for your evaluation, but it seems this is a racing condition or however a kind of assumption in jquery code that doesn't work with my page.

I found using the debugger that jquery 1.6.1 fails inside its "clean" function I reported below.


Inside the clean function JQuery does a:

div = context.createElement("div");

...later it executes the following which is resulting in a null "div" variable.

Move to the right depth

while ( depth-- ) {

div = div.lastChild;

} the end of the clean function we have a "null pointer" trying to use the null div variable:

elem = div.childNodes;

Pratically I see here two problems:

1) There is an assumption that the created div has child nodes

2) There is not a protection against the null pointer

In order to workaround this error I should understand what's wrong in my code (I mean: what jquery don't like in my valid xhtml 1.0)

I would appreciate some suggestions as I can't understand the logic of the clean function code, sorry.

Thank you in advance.

JQuery's Clean function code


clean: function( elems, context, fragment, scripts ) {

var checkScriptType;

context = context || document;

!context.createElement fails in IE with an error but returns typeof 'object'

if ( typeof context.createElement === "undefined" ) {

context = context.ownerDocument || context[0] && context[0].ownerDocument || document;


var ret = [], j;

for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {

if ( typeof elem === "number" ) {

elem += "";


if ( !elem ) {



Convert html string into DOM nodes

if ( typeof elem === "string" ) {

if ( !rhtml.test( elem ) ) {

elem = context.createTextNode( elem );

} else {

Fix "XHTML"-style tags in all browsers

elem = elem.replace(rxhtmlTag, "<$1></$2>");

Trim whitespace, otherwise indexOf won't work as expected

var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),

wrap = wrapMap[ tag ] || wrapMap._default,

depth = wrap[0],

div = context.createElement("div");

Go to html and back, then peel off extra wrappers

div.innerHTML = wrap[1] + elem + wrap[2];

Move to the right depth

while ( depth-- ) {

div = div.lastChild;


Remove IE's autoinserted <tbody> from table fragments

if ( ! ) {

String was a <table>, *may* have spurious <tbody>

var hasBody = rtbody.test(elem),

tbody = tag === "table" && !hasBody ?

div.firstChild && div.firstChild.childNodes :

String was a bare <thead> or <tfoot>

wrap[1] === "<table>" && !hasBody ?

div.childNodes :


for ( j = tbody.length - 1; j >= 0 ; --j ) {

if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {

tbody[ j ].parentNode.removeChild( tbody[ j ] );




// IE completely kills leading whitespace when innerHTML is used

if ( ! && rleadingWhitespace.test( elem ) ) {

div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );


elem = div.childNodes;



Changed June 07, 2011 07:09AM UTC by anonymous comment:5


JQuery raises "o is null" or "div is null" during the "clean" action with an XHTML page that uses JQuery and JQuery UI with the XML processing instruction at the top.

The behaviour of JQuery is correct to identify an XML processable document using the processing instruction, but XHTML is actually an XML file and it is correct to use the processing instruction or it as well.

I really think JQuery should look at the doctype to verify if it is an XHTML page before reading the page as XML.

This way JQueryUI doesn't work:

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE html PUBLIC "-W3CDTD XHTML.............

This is ok.

<!DOCTYPE html PUBLIC "-W3CDTD XHTML.............

Hope this help