Side navigation
#8380 closed bug (fixed)
Opened February 25, 2011 02:23PM UTC
Closed March 21, 2011 03:11PM UTC
Last modified March 09, 2012 08:04AM UTC
$(':text') should match <input> since `type=text` is the implied default
Reported by: | mathias | Owned by: | john |
---|---|---|---|
Priority: | blocker | Milestone: | 1.5.2 |
Component: | selector | Version: | 1.5.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Test case: http://jsfiddle.net/mathias/CpvgM/
Currently, $(':text') only matches inputs with type=text explicitly set. It should also match <input>
since type=text is the implied default in all browsers (as per the HTML spec).
Attachments (0)
Change History (18)
Changed February 25, 2011 02:25PM UTC by comment:1
Changed February 25, 2011 02:50PM UTC by comment:2
Here’s a fix: https://github.com/jeresig/sizzle/pull/52
Changed February 25, 2011 05:44PM UTC by comment:3
cc: | → snover |
---|---|
component: | unfiled → selector |
priority: | undecided → low |
status: | new → open |
Thanks. The pull request looks fairly decent - CC'ing snover for further review.
Changed February 25, 2011 06:53PM UTC by comment:4
We talked about this on -dev today, it seems like a good idea. However we should discourage <input />
in markup since it does not match qSA for input[type=text]
-- the attribute is missing, only the property is "text".
Changed February 28, 2011 03:14AM UTC by comment:5
It is critical regression for my projects, I did not set type attribute for text input _several years_.
So now I need edit and test tons of HTML/XSL/PHP/JS templates to upgrade to jQuery 1.5.1?
Changed February 28, 2011 07:42AM UTC by comment:6
@dmifedorenko: Actually, no. $(':text')
should match <input>
and it has always worked that way before jQuery 1.5.1 was released. The regression you’re talking about is in 1.5.1, and this patch will fix it.
Changed February 28, 2011 06:41PM UTC by comment:7
milestone: | 1.next → 1.5.2 |
---|---|
priority: | low → blocker |
Changed March 01, 2011 06:11PM UTC by comment:9
I probably introduced this bug in 1.5.1 - https://github.com/gnarf37/sizzle/commit/0048e13aa17bd805374784f7d6e6f6f0a0140fe7 -- Before that commit,
:textjust did "text" === elem.type -- we could potentially revert that function (not the whole commit since
:textis a Sizzle only "magic" selector it can do whatever we need it to.
If you want to override this in 1.5.1 for your own regression purposes its a one line fix:
jQuery.find.selectors.filters['text'] = function(elem) { return "text" === elem.type };
Changed March 01, 2011 06:11PM UTC by comment:10
cc: | snover |
---|
Changed March 04, 2011 04:13PM UTC by comment:11
Wouldn't this work? (to replace line 619 from https://github.com/gnarf37/sizzle/commit/0048e13aa17bd805374784f7d6e6f6f0a0140fe7)
return "text" === (elem.getAttribute( 'type' ) || "text");
As it will return the value of type, and if this is null, it will return the default: "text".
Changed March 07, 2011 04:55PM UTC by comment:12
owner: | → john |
---|---|
status: | open → assigned |
Changed March 20, 2011 10:02PM UTC by comment:13
#8565 is a duplicate of this ticket.
Changed March 21, 2011 03:11PM UTC by comment:14
resolution: | → fixed |
---|---|
status: | assigned → closed |
Landed mathias' pull request.
Changed March 21, 2011 03:35PM UTC by comment:15
keywords: | → needsdocs |
---|
Changed March 21, 2011 03:35PM UTC by comment:16
Per matjas: [8:29 AM] <matjas> now that #8380 is fixed, the text on http://api.jquery.com/text-selector/ needs some tweaking
Changed March 22, 2011 03:11PM UTC by comment:17
#8583 is a duplicate of this ticket.
Changed March 28, 2011 02:30AM UTC by comment:18
keywords: | needsdocs |
---|
updated documentation
For the record, when this is fixed, the docs should probably be updated as well: http://api.jquery.com/text-selector/