jQuery :last-of-type pseudo-class not working anymore--maybe a FF3 thing?

mikesmullin - April 19, 2009 - 03:04
Project:Drupal
Version:5.16
Component:upload.module
Category:bug report
Priority:normal
Assigned:Unassigned
Status:postponed (maintainer needs more info)
Description

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.

AttachmentSizeStatusTest resultOperations
upload.js_.last_of_type.patch841 bytesIgnoredNoneNone

#1

drumm - May 13, 2009 - 16:49
Status:needs review» postponed (maintainer needs more info)

This may be an issue with your theme or a module? Please try enabling one thing at a time on a test site.

#2

cburch - October 20, 2009 - 14:03

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.

 
 

Drupal is a registered trademark of Dries Buytaert.