jQuery :last-of-type pseudo-class not working anymore--maybe a FF3 thing?
| Project: | Drupal |
| Version: | 5.16 |
| Component: | upload.module |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Jump to:
I am not sure why this is broken now or why nobody has caught it until now, but I am guessing something outside Drupal changed recently. Maybe the browser upgrade from FF2 to FF3. At any rate, to reproduce simply try uploading more than one file to a node and on the second file you will get a JavaScript error and the "File attachments" fieldset will be left blank (e.g. no file uploads listed, where previously there was one because the first file you upload does work).
It becomes blank because the code calls $.empty() and then attempts to replace with XHTML markup passed via AJAX, but has an error along the way trying to use $() to select a DOM element.
The fix I found was to replace the :last-of-type CSS pseudo class with the safer equivalent of :last CSS pseudo class.
(see attached patch)
Although, strange thing, I just tried it with the d.o form and it's not breaking. Hmm... maybe there is another factor involved here. Will submit issue anyway and see if anyone else can confirm.
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| upload.js_.last_of_type.patch | 841 bytes | Ignored | None | None |

#1
This may be an issue with your theme or a module? Please try enabling one thing at a time on a test site.
#2
I had this same problem. On lines 77 and 90 of misc/upload.js, changing:
tr:last-of-type
to:
tr:last
solved the problem.