... and why it matters
In the list of things changed for jQuery 1.8, you might miss this one, buried deep in the change log:
#9400: Deprecate :text, :radio, :checkbox, etc. selector extensions
Sure enough.. it's got the scarlet letter "Deprecated" tag. What the...? These jQuery pseudo-selectors are probably the first thing I ever learned about using jQuery. This seems to be a... confusing move at best.
Most of these jQuery extension selectors are easily replaced using longform CSS. Indeed, this is the rationale presented with the original request: they're redundant. For example,
:checkbox is literally the same as
input[type=checkbox]. While I've always like the terseness of the jQuery aliases, I could live without them.
The problem is specifically with
:text selector. The CSS version
input[type=text] does not work the same as the jQuery
:text selector. This is because when there's no
:text will select it, and the CSS version will not. CSS works only against actual attributes in the markup. This is important with "text" inputs because "text" is the default value. It's perfectly legal, valid, and even encouraged by some (because it's terse), to omit the "type" attribute for the ubiquitous text input. The simplest possible text input is just
Behold, a textbox, which you will then style with jQuery...
Okay, this is not the end of the world. "Deprecated" is a lot different from "removed." jQuery contains features that were deprecated years ago, and it's not especially likely that this is going to be removed any time soon. But most people are uncomfortable writing new code that uses features they know are slated for future removal. So, starting with jQuery 1.8, you need to either choose to always have a "type" attribute, even though it's not required, or use a feature that's been deprecated to select all "text" inputs.
So, this post is mostly an observation. If at some point in the future
:text stopped working, you could always use a simple plugin to replace it. No big deal. But it's certainly a curious feature to remove. It's at the core of jQuery's original purpose: making it easy to work with HTML; filling the void left by the DOM and CSS. The
:text filter clearly fills such a void; this change undoes something useful.