Bug Tracker

Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#4218 closed bug (fixed)

Regression: jQuery 1.3 only accepts upper case node names in HTML

Reported by: stephen.friedrich Owned by: john
Priority: major Milestone: 1.4
Component: selector Version: 1.4a1
Keywords: Cc:
Blocked by: Blocking:

Description

I develop a web app with JSF using JBoss RichFaces and its ajax-Framework Ajax4Jsf (a4j).

When trying to upgrade from jQuery 1.2.6 to 1.3 I noticed that after executing an a4j-Request, jQuery no longer worked correctly on that page: Selectors returned an empty list, where they shouldn't.

After researching and with some help from the irc chat I narrowed the problem: DOM elements that are replaced by a4j have lower case node names. jQuery 1.2.x did not care about upper/lower case difference in nodeNames.

However jQuery 1.3 converts the selector to upper case in HTML files, see for example line 1681 of jQuery 1.3.2:

if ( isTag && !isXML ) {

part = part.toUpperCase();

}

Yet, when trying to match against a DOM element's nodeName, a case sensitive match is done, so that elements with lower case nodeName do not match, see for example line 1689:

elem.nodeName === part

I'll try to come up with an example file, but I have to research how a4j does the dom replacement to mimick this use case.

Attachments (4)

ajax-test.html (2.1 KB) - added by stephen.friedrich 10 years ago.
Here's a test file to reproduce the behaviour
jQuery.patch (1.4 KB) - added by stephen.friedrich 10 years ago.
Patch for jQuery 1.3.2 that fixes this problem
jquery-1.3.2.js (117.8 KB) - added by stephen.friedrich 10 years ago.
Patched (debug) version of jQuery 1.3.2
ajax-test2.html (5.2 KB) - added by manus 10 years ago.
contains some tests for different selectors; hope this helps!

Download all attachments as: .zip

Change History (28)

comment:1 Changed 10 years ago by stephen.friedrich

Oh, forgot to add: This happens only on Firefox. IE seems to work fine.

Changed 10 years ago by stephen.friedrich

Attachment: ajax-test.html added

Here's a test file to reproduce the behaviour

comment:2 Changed 10 years ago by vlopez

I have the same problem. Please answer this ticked! I want to use the new version but I can't cause of this.

comment:3 Changed 10 years ago by vlopez

Does anybody know a solution for this? I realy need use the new version of jQuery for better performance on my site. Thank you.

comment:4 Changed 10 years ago by laixer

I just ran into this same issue today... Are there any plans to address this?

comment:5 Changed 10 years ago by laixer

Okay, I did some investigating and as far as I can tell, the problem is that the isXML() function returns false for XHTML documents, when it should return true.

comment:6 Changed 10 years ago by lavoie.alexandre

Same problem here, is there a workaround for the moment? Still moving a project to production and need the jQuery 1.3 with RichFaces!

comment:7 Changed 10 years ago by laixer

doesn't seem like we're going to get a response from the jquery team for this one... i'm probably going to fix this myself within the next couple of weeks because I need it for a production application as well. I'll let you know if I find a fix...

comment:8 Changed 10 years ago by stephen.friedrich

Please find attached a patch that _works for me_. I changed some comparisons to be case insensitive.

I attach both the patch file, so that you can quickly see my changes as well as the complete patched jQuery debug version file.

I _don't_ suggest that these are the changes that should be commited to jQuery's svn: I just can't fully determine what effects these changes have especially when using jQuery in XML context.

Changed 10 years ago by stephen.friedrich

Attachment: jQuery.patch added

Patch for jQuery 1.3.2 that fixes this problem

Changed 10 years ago by stephen.friedrich

Attachment: jquery-1.3.2.js added

Patched (debug) version of jQuery 1.3.2

comment:9 Changed 10 years ago by laixer

Thank you Stephen, I'm trying out now. So far so good.

comment:10 Changed 10 years ago by vlopez

Works fine to me! Thank you Stephen.

comment:11 Changed 10 years ago by laixer

I haven't encountered any problems since I've used your patch. Thanks!

comment:13 Changed 10 years ago by manus

I also ran into this bug recently and am so glad it is known and documented. Hopefully all this selector madness is fixed in Sizzle 1.0. Also, kudos to Stephen for the test & patch, though you're right in your guess that it's more complicated than is seems. I was playing around with your test file and came up with a small (nonexhaustive) suite of tests, which I'm attaching -- Stephen's patch only fixes a couple specific ones.

comment:14 Changed 10 years ago by manus

A related interesting bug, and possibly another symptom of the root cause, is the 'element.className' selector behavior after DOM refresh (test case #7 in the file I attached). AFAICT, the result here is the only one that changes between FF 2 and 3.0. (Should I file this as a separate bug?)

It's also interesting that no version of jQuery passes all the tests. :/ Am I missing something?

Changed 10 years ago by manus

Attachment: ajax-test2.html added

contains some tests for different selectors; hope this helps!

comment:15 Changed 10 years ago by manus

I just updated the file so it can be tested on Opera as well, which also shows some irregularities.

comment:16 Changed 10 years ago by triplepoint

There are several bugs related to this one, notably #4400, #3985 and #4895.

These additional bugs all deal with XHTML generated by client-side XSL. Firefox (and only firefox) uses the native case for the tag names in the generated XHTML, instead of the all-caps javascript standard for HTML. So jQuery selectors fail.

This is a similar situation to the ajax-inserted content described in this bug.

There's an additional failure example that we found in the contextMenu plugin:

$('#some_id').find('LI:not(.disabled) A')

will fail, while

$('#some_id').find('LI:not(.disabled)').find('A')

Does not.

I'm not sure if this additional case throws any light on the selector failures, hope it helps.

comment:17 Changed 10 years ago by manus

Thanks for the investigation and for finding those related bugs!

I think there's a bunch of selector madness going on, not just in Firefox. Take a look at the attached ajax-test2.html in FF or Opera, and you'll see failures in both. There are also differences in results between FF 3.0.x and 3.5.

Also, the additional failure case you noticed can be seen in test cases 9-12 (11 & 12 use find()). Specifically, comparing before and after outputs from test case 11 shows that the case of the resulting tagnames in the derived selector are different. Weird!

Anyway, this ticket is apparently on John Resig's radar & to-do list: http://groups.google.com/group/jquery-dev/browse_thread/thread/e39fd327abc66bdd (sorry to cross-post)

...so hopefully he'll get a chance to check it out more closely.

comment:18 Changed 10 years ago by manus

Sorry, I meant:

"... comparing before and after outputs from test case 11 shows that the case of the resulting tagnames of the found elements are different."

comment:19 Changed 10 years ago by triplepoint

Any progress on this bug from anyone? The selector breakage in Firefox is a Big Deal.

comment:20 Changed 9 years ago by towers

Hi, I have test the patch with 'quicksearch' plugin and now it works fine.

But, the 'jCarousel' does not works with this patch in FF 3.0 :(

Is there a new solution? or other solution newer?

Greetings.

comment:21 Changed 9 years ago by towers

I just have found the solution to this problem in 'jCarousel' plugin.

The line 111:

if (e.nodeName == 'UL'
e.nodeName == 'OL') {

must be changed to:

var FF = /Firefox/.test(navigator.userAgent);

if (( !FF && (e.nodeName == 'UL'
e.nodeName == 'OL') ) ( FF && (jQuery.nodeName(e,'UL')) (jQuery.nodeName(e,'OL')) )) {

Greetings.

comment:22 Changed 9 years ago by towers

The paste has not work in the before post, the second if is:

if ( ( !FF && (e.nodeName == 'UL'
e.nodeName == 'OL') ) ( FF && (jQuery.nodeName(e,'UL')) (jQuery.nodeName(e,'OL')) ) ) {

(between e.nodeName == 'UL' and e.nodeName == 'OL' there is an OR operator, and between 'OL') ) and ( FF && there is other OR operator, and between (jQuery.nodeName(e,'UL')) and (jQuery.nodeName(e,'OL')) other OR).

comment:23 Changed 9 years ago by dmethvin

Component: unfilledselector
Owner: set to john

comment:24 Changed 9 years ago by john

Resolution: fixed
Status: newclosed

comment:25 Changed 9 years ago by john

Version: 1.3.21.4a1
Note: See TracTickets for help on using tickets.