Bug Tracker

Opened 13 years ago

Closed 12 years ago

Last modified 11 years ago

#6162 closed bug (invalid)

CLASS function with XHTML DocumentFragment: elem.getAttribute is not a function

Reported by: janmoesen Owned by: janmoesen
Priority: undecided Milestone: 1.4.2
Component: attributes Version: 1.4.1
Keywords: Cc:
Blocked by: Blocking:


Since jQuery 1.4, my XHTML web-app (too vague, I know) throws a fatal error in the |CLASS| function. Apparently, the |elem| that is being used is not an element but a |DocumentFragment|.

When I switch the |Content-Type| to |text/html|, the problem is gone.

I have hackily patched the |CLASS| function in jquery-1.4.2.js on line 3269 to check for a |firstChild| as follows:

var className = elem.className; if (!className) {

if (elem.getAttribute) {

className = elem.getAttribute('class');

} else if (elem.firstChild && elem.firstChild.getAttribute) {

className = elem.firstChild.getAttribute('class');


} return (" " + className + " ").indexOf( match ) > -1;

The patches from ticket #5706 dit not help. Does this bug also fall under "We're going to tackle this, and a number of other XML/XHTML/XUL/SVG related issues post-1.4. Thanks for the patch!"

Change History (9)

comment:1 Changed 13 years ago by janmoesen

Is there anything I can do to move this forward? We have had to revert our application/xhtml+xml to text/html because of this, and are eager to go back.

comment:2 Changed 13 years ago by Cédric

I've got problems with XHTML too. Look http://dev.jquery.com/ticket/5847

comment:3 Changed 12 years ago by Rick Waldron

Keywords: needsreview added
Owner: set to janmoesen
Priority: undecided
Status: newpending

Please provide a reduced jsFiddle test case, thanks!

Additionally, test against the jQuery 0 GIT version to ensure the issue still exists.

comment:4 Changed 12 years ago by snover

#5847 is a duplicate of this ticket.

comment:5 Changed 12 years ago by snover

#7642 is a duplicate of this ticket.

comment:6 Changed 12 years ago by [email protected]

I did a try with jquery-git.js and the problem remain.

I saved the test case as http://jsfiddle.net/Qekyj/ but you cannot verify it using jsFiddle because the problem is in some way related to the mime type and I can't set it.

There is a little test case in the ticket #7642

this one works: http://elrond.aspix.it/jquery/test.html

this one no: http://elrond.aspix.it/jquery/test.xhtml

comment:7 Changed 12 years ago by trac-o-bot

Resolution: invalid
Status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

comment:8 Changed 12 years ago by [email protected]

This bug looks like it was marked as "invalid" due to inactivity--probably due to the end-of-year holiday season.

This is still a problem. When a web server's response MIME type is "application/xhtml+xml", jQuery has errors as indicated in this bug as well as its duplicates.

This applies to v1.4.4.

Comment 6 by [email protected]… seems to have the best test case.

comment:9 Changed 12 years ago by snover

Keywords: needsreview removed

This is an XML problem.

Note: See TracTickets for help on using tickets.