Ticket #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: | ||
| Blocking: | Blocked by: |
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!"
Change History
comment:2 Changed 3 years ago by Cédric
I've got problems with XHTML too. Look http://dev.jquery.com/ticket/5847
comment:3 Changed 3 years ago by rwaldron
- Keywords needsreview added
- Owner set to janmoesen
- Status changed from new to pending
- Priority set to undecided
Please provide a reduced jsFiddle test case, thanks!
Additionally, test against the jQuery 0 GIT version to ensure the issue still exists.
comment:6 Changed 2 years ago by edoardo@…
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 2 years ago by trac-o-bot
- Status changed from pending to closed
- Resolution set to invalid
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 2 years ago by rick.roth@…
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.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

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.