Skip to main content

Bug Tracker

Side navigation

#6162 closed bug (invalid)

Opened February 24, 2010 02:39PM UTC

Closed December 13, 2010 07:52AM UTC

Last modified March 13, 2012 11:47PM UTC

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:
Description

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!"

Attachments (0)
Change History (9)

Changed March 11, 2010 01:32PM UTC by janmoesen comment:1

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.

Changed April 25, 2010 06:35PM UTC by Cédric comment:2

I've got problems with XHTML too.

Look http://dev.jquery.com/ticket/5847

Changed October 29, 2010 04:59PM UTC by rwaldron comment:3

keywords: → needsreview
owner: → 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.

Changed November 22, 2010 04:53AM UTC by snover comment:4

#5847 is a duplicate of this ticket.

Changed November 27, 2010 10:56PM UTC by snover comment:5

#7642 is a duplicate of this ticket.

Changed November 28, 2010 03:15PM UTC by edoardo@aspix.it comment:6

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

Changed December 13, 2010 07:52AM UTC by trac-o-bot comment:7

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!

Changed January 03, 2011 09:31PM UTC by rick.roth@live.com comment:8

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 edoardo@… seems to have the best test case.

Changed January 23, 2011 05:16PM UTC by snover comment:9

keywords: needsreview

This is an XML problem.