Ticket #9261 (closed bug: fixed)
Has Attribute not working in filter/children/siblings
| Reported by: | ari@… | Owned by: | timmywil |
|---|---|---|---|
| Priority: | blocker | Milestone: | 1.7 |
| Component: | selector | Version: | 1.6 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: | #7128 |
Description
When attempting to match empty attributes in filter() and equivalent functions, the Has Attribute selector fails in all browsers unless an equals sign is used: [tag] fails [tag=] works
{{{<table>
<tr>
<td></td> <td data-info=""></td> <td></td> <td class='test'></td> <td></td> <td></td>
</tr>
</table>
console.log($('td.test').siblings('td[data-info]')); Why does this not work when console.log($('td.test').parent().find('td[data-info]')); This works console.log($('td.test').siblings('td[data-info=]')); And this works
console.log($('td.test').siblings().filter('td[data-info]')); This doesn't work either. console.log($('td.test').parent().children('td[data-info]')); Neither does this.}}}
Change History
comment:1 Changed 2 years ago by timmywil
- Priority changed from undecided to blocker
- Status changed from new to open
- Component changed from unfiled to selector
- Blocked by 7128 added
- Milestone changed from 1.next to 1.7
comment:3 Changed 2 years ago by anonymous
Just to be sure we're all clear here... The has attribute selector *will* select elements with empty attributes when doing jQuery('[emptyAttribute]'). It is only filter and friends that fail in this regard. The inconsistency is as confusing as anything. Considering all the attr() work in 1.6, it would be nice to not have to wait for 1.7 for a fix to an attribute-related bug.
comment:4 Changed 2 years ago by timmywil
We have seen problems with straight selections. It's not specific to filter or related methods. This needs to wait until 1.7 as Sizzle will start using jQuery's attribute/property handling for consistent selectors across the board.
comment:7 Changed 22 months ago by timmywil
- Owner set to timmywil
- Status changed from open to assigned
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
