Ticket #9594 (closed bug: duplicate)
attr selectors in find, find nothing
| Reported by: | funkjunky8 | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | 1.next |
| Component: | selector | Version: | 1.6.1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
jQuery 1.6 Chrome 11 Mac OS X Snow Leopard JSFiddle: http://jsfiddle.net/ScN4a/
alert(newKeyValueRow.find('input[name*="from"]').length);
alert(newKeyValueRow.find('input[name~="from"]').length); alert(newKeyValueRow.find('input[name|="bucket_from"]').length); alert(newKeyValueRow.find('input[name]').eq(1).attr("name"))
These output: 1 0 0 bucket_from[0][]
The html is as follows (taken from the developer tools of chrome): <tr class="bucketRow"> <td> <input type="text" name="bucket_to[0]" value=""></td> <td class="bucketValueTD"><= <input type="text" name="bucket_from[0][]" value=""> <input type="button" class="bucket_add_row" value="add value"> </td> </tr>
JSFiddle: http://jsfiddle.net/ScN4a/ (note: I put the alerts into a click of the button.)
As far as I understand, the first two alerts ABSOLUTELY should show the same thing. The third one should as well, but it is a little less obvious, although still fairly obvious.
Change History
comment:1 Changed 2 years ago by timmywil
- Priority changed from undecided to high
- Resolution set to duplicate
- Status changed from new to closed
- Component changed from unfiled to selector
comment:3 Changed 2 years ago by funkjunky8
If you insist. The bug referenced appears to refer to the attribute existing, while my bug expands the issue to matching attributes using specific selectors.
comment:4 Changed 2 years ago by dmethvin
- Priority changed from high to low
You're right, it's not a dup, I think it's invalid.
~= is the "contains word" selector; input[name~="from"] shouldn't match anything because there is no *space-delimited* string from in the markup. http://api.jquery.com/attribute-contains-word-selector/
|= is the "contains prefix" selector; input[name|="bucket_from"] shouldn't match anything because there is no name that is either exclusively that string or prefix that string *followed by a dash*. http://api.jquery.com/attribute-contains-prefix-selector/
It's best to start on the forum with questions like this and only file a bug once you've got some consensus that it's really a bug.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
