Skip to content


Subversion checkout URL

You can clone with
Download ZIP


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

merged 2 commits into from

3 participants


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:
Form selector deprecation ticket:

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


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.


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.


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.


Needs to be tested/validated.


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


This change is backward compatible and as per

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 neerajdotname merged commit a2a7721 into rails:master

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


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
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/rails.js
6 src/rails.js
@@ -82,7 +82,7 @@
requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])',
// Form file input elements
- fileInputSelector: 'input:file',
+ fileInputSelector: 'input[type=file]',
// Link onClick disable selector with possible reenable after remote submission
linkDisableSelector: 'a[data-disable-with]',
@@ -257,12 +257,12 @@
allInputs.each(function() {
input = $(this);
- valueToCheck =':checkbox,:radio') ?':checked') : input.val();
+ valueToCheck ='input[type=checkbox],input[type=radio]') ?':checked') : input.val();
// If nonBlank and valueToCheck are both truthy, or nonBlank and valueToCheck are both falsey
if (!valueToCheck === !nonBlank) {
// Don't count unchecked required radio if other radio with same name is checked
- if (':radio') && allInputs.filter('input:radio:checked[name="' + input.attr('name') + '"]').length) {
+ if ('input[type=radio]') && allInputs.filter('input[type=radio]:checked[name="' + input.attr('name') + '"]').length) {
return true; // Skip to next input
Something went wrong with that request. Please try again.