Skip to main content

Bug Tracker

Side navigation

#9261 closed bug (fixed)

Opened May 12, 2011 07:04PM UTC

Closed September 19, 2011 07:43PM UTC

Last modified March 08, 2012 05:47PM UTC

Has Attribute not working in filter/children/siblings

Reported by: ari@asu.edu Owned by: timmywil
Priority: blocker Milestone: 1.7
Component: selector Version: 1.6
Keywords: Cc:
Blocked by: Blocking:
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

http://jsfiddle.net/peRvp/2/

<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.
Attachments (0)
Change History (8)

Changed May 12, 2011 07:43PM UTC by timmywil comment:1

blockedby: → 7128
component: unfiledselector
milestone: 1.next1.7
priority: undecidedblocker
status: newopen

Changed May 12, 2011 07:44PM UTC by timmywil comment:2

let's handle this has attribute stuff in 1.7.

Changed May 17, 2011 04:17PM UTC by anonymous comment:3

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.

Changed May 17, 2011 04:22PM UTC by timmywil comment:4

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.

Changed May 27, 2011 12:11AM UTC by timmywil comment:5

#9424 is a duplicate of this ticket.

Changed June 15, 2011 07:11PM UTC by timmywil comment:6

#9594 is a duplicate of this ticket.

Changed July 25, 2011 04:15PM UTC by timmywil comment:7

owner: → timmywil
status: openassigned

Changed September 19, 2011 07:43PM UTC by timmywil comment:8

resolution: → fixed
status: assignedclosed

Override Sizzle attribute retrieval with jQuery.attr. Fixes #5637, #7128, #9261, #9570, #10178.

Bug fixed on the side: $(window).is('a') was throwing an exception. Fixes #10178.

Changeset: 92405d4f5ffe9ec1f26f280303783014948438c5