Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Update deprecated form selectors (:file, :radio, etc.) #291

Merged
merged 2 commits into from Jan 24, 2013

Conversation

Projects
None yet
3 participants
Contributor

javierjulio commented Nov 19, 2012

Shorthand form selectors in jQuery such as :file, :radio, :checkbox and others have been deprecated. I've replaced any instances with the standard type which has always been supported. For example, :file now is input[type=file]. There are a few instances in rails.js where this was already being done so I stuck to the same format (no quotes on attribute value).

Deprecation details: http://api.jquery.com/category/deprecated/.
Form selector deprecation ticket: http://bugs.jquery.com/ticket/9400

Using the standard selector (e.g. input[type=file]) provides better performance in modern browsers.

Contributor

javierjulio commented Dec 21, 2012

Unless I'm mistaken support for several colon prefixed selectors (which this pull request updates to use standard ones) are being removed from jQuery 1.9 which is the next release. Today the jQuery team released 1.9 beta 1.

Member

JangoSteve commented Dec 22, 2012

Thank you. I'll be able to take a look at this in the next week I think. We'll have to figure out how to make this work also with jQuery 1.8, or wait until 1.9 comes out of beta.

Contributor

javierjulio commented Dec 22, 2012

Is their something I'm missing that it wouldn't work with jQuery 1.8? Or it just needs to be tested/validated? This will work with previous versions of jQuery since the standard selector has always been supported, its just the shorthand versions are getting phased out (most, not all). I wasn't sure if tests needed to be written for this case since its jQuery functionality. Happy to help out though. Thanks.

Member

JangoSteve commented Dec 22, 2012

Needs to be tested/validated.

Member

JangoSteve commented Jan 19, 2013

By the way, these weren't removed in jquery 1.9, but I'll take a look.

Member

neerajdotname commented Jan 24, 2013

This change is backward compatible and as per http://api.jquery.com/file-selector/

Because :file is a jQuery extension and not part of the CSS specification, queries using :file cannot take advantage of the performance boost provided by the native DOM querySelectorAll() method. For better performance in modern browsers, use [type="file"] instead.

neerajdotname pushed a commit that referenced this pull request Jan 24, 2013

Merge pull request #291 from javierjulio/update-deprecated-selectors
Update deprecated form selectors (:file, :radio, etc.)

@neerajdotname neerajdotname merged commit a2a7721 into rails:master Jan 24, 2013

Member

JangoSteve commented Jan 24, 2013

Awesome, thanks for catching us up on all these, @neerajdotname. I've been a bit swamped.

Contributor

javierjulio commented Jan 24, 2013

Awesome! Glad to see this change go through. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment