Bug Tracker

Opened 11 years ago

Closed 9 years ago

#4352 closed enhancement (wontfix)

Support $("string") in XUL

Reported by: acoder Owned by:
Priority: minor Milestone: 1.4
Component: core Version: 1.3.2
Keywords: innerHTML XUL Cc:
Blocked by: Blocking:

Description

I'm using jQuery 1.3.2 in an Firefox extension but I keep getting the error "div is null" on line 940.

I'm loading jQuery like this in my chrome overlay:

<script type="application/x-javascript"

src="chrome://extensionname/content/jquery-1.3.2.js"/>

Attachments (3)

screen-capture-1.png (43.6 KB) - added by jbownds 11 years ago.
Error in line 940!
bug-4352-testcase.zip (36.8 KB) - added by dmachera 10 years ago.
test case for #4352
stack.rtf (33.8 KB) - added by jbownds 10 years ago.
Contents of variable named "stack" returned with error when I try/catch jqueryUI stuff.

Download all attachments as: .zip

Change History (13)

comment:1 Changed 11 years ago by dmethvin

Can you provide a complete test case? It's not possible to reproduce the problem with only the information provided.

comment:2 Changed 11 years ago by acoder

I can no longer reproduce the error so you should probably close this bug.

comment:3 Changed 11 years ago by jbownds

I'm experiencing the same thing. It's limited to the use of jquery UI functions. So, for example,

Add a wrapper: foo.wrapper= $('<div id="foo">').appendTo(masthead).html("&nbsp;");

Pull in some html. . no problem. $(foo.wrapper).load("http://foobar.com/foo.html", "", rebind);

Add some CSS in the callback (rebind), no problem. $(foo.wrapper).css("border","3px solid red");

Fade the Div out in the callback, no problem. $(serum.wrapper).fadeOut("slow");

Do anything at all related to jqueryUI, and bork. The attached error can be caught (see attached image), but if the statement isn't wrapped in a try catch, everything just dies.

$(serum.wrapper).accordion(); Nogo.

$(serum.wrapper).tabs(); / Same problem.

We're calling 1.3.2 in the chrome overlay as well, but from a remote spot. I've tried calling it from different locations (the hosted Google instances here: http://code.google.com/apis/ajaxlibs/documentation/index.html#jquery for example) and run into the same issue.

Changed 11 years ago by jbownds

Attachment: screen-capture-1.png added

Error in line 940!

comment:4 Changed 11 years ago by jbownds

Worthy of note. . When I run the nightly build instead of 1.3.2, this problem is resolved. I've confirmed by toggling between builds that the issue has been resolved somewhere between 1.3.2 and the head. .

comment:5 Changed 11 years ago by jhilden

I have the same issue trying to use .append() in my extension with jQuery 1.3.2

Changed 10 years ago by dmachera

Attachment: bug-4352-testcase.zip added

test case for #4352

comment:6 Changed 10 years ago by dmachera

This bug seems to exist in both the 1.3.2 and nightly (2009-03-22 21:55:17 -0400 (Sun, 22 Mar 2009)) releases.

To replicate this bug it is probably worthwhile to set up a firefox extension environment (https://developer.mozilla.org/en/Setting_up_extension_development_environment)

Unzip the attached test-case (bug-4352-testcase.zip), then create a file called 'bug-4352@…' with the contents being the full path to this test-case i.e. '/home/dan/bug-4352/', make sure to place this file in your mozilla extensions directory

The bug is exposed on line 9 of bug-4352.js, which causes line 940 of jquery (1.3.2) to output 'div is null' to the error console, here is the jquery line throwing the error:

elem = jQuery.makeArray(div.childNodes);

If any more info is required, ask away.

Ta

comment:7 Changed 10 years ago by jbownds

Alas- I'm running into this again. This time in line 2304, not sure if the line is significant. Tried updating to a nightly build, still fails. I'll attach the stack returned when I capture the error with a try/catch.

Changed 10 years ago by jbownds

Attachment: stack.rtf added

Contents of variable named "stack" returned with error when I try/catch jqueryUI stuff.

comment:8 Changed 10 years ago by jbownds

Worthy of note. .

Line 2304, where the code fails, is

elem = jQuery.makeArray(div.childNodes);

(see dmachera's comment above. . )

comment:9 Changed 10 years ago by dmethvin

Component: unfilledcore
Keywords: innerHTML XUL added
Priority: criticalminor
Summary: "div is null" when used with XULSupport $("string") in XUL
Type: bugenhancement

The $(html) constructor is meant to parse HTML (not XML or XUL):

http://docs.jquery.com/Core/jQuery#htmlownerDocument

jQuery uses the innerHTML property of a div to convert an HTML string to DOM nodes. It doesn't appear that XUL supports innerHTML so you can't use $(html) and would need to create the nodes via DOM or a plugin. Here's what I found:

http://digitalmihailo.blogspot.com/2008/05/jquery-and-dynamic-html-in-xul.html

http://www.scribd.com/doc/88692/jeff-griffithsphp-xul-jquery

I've edited this ticket to change it to an enhancement request.

comment:10 Changed 9 years ago by dmethvin

Resolution: wontfix
Status: newclosed

This doesn't seem like a feature we'd ever include in core; the best way to support this would be through a XUL plugin.

Note: See TracTickets for help on using tickets.