Ticket #7485 (closed bug: fixed)
Inconsistency between has [attribute] selector and attr() method
| Reported by: | jitter | Owned by: | |
|---|---|---|---|
| Priority: | blocker | Milestone: | 1.6 |
| Component: | attributes | Version: | 1.5.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
While checking on #7480 I noted a related bug.
There are inconsistencies when using the has [attr] selector and the attr() method.
The selector doesn't return all elements which have the attribute although upon checking with the attr() method it returns a value.
test case with text attribute not explicitly defined
test case with text attribute explicitly defined on some elements
Change History
comment:1 Changed 3 years ago by snover
- Priority changed from undecided to blocker
- Status changed from new to open
- Component changed from unfiled to attributes
- Blocked by 7128 added
comment:2 Changed 2 years ago by john
- Milestone changed from 1.5 to 1.6
This is getting moved to 1.6 for when the $.attr happens.
comment:4 Changed 2 years ago by timmywil
- Status changed from open to closed
- Version changed from 1.4.4 to 1.5.2
- Resolution set to fixed
The nodes in question do not have content attributes called "text" and therefore should not be found by either one. http://jsfiddle.net/timmywil/znVBU/2/
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

This is something on the roadmap for 1.5. .attr will be rewritten along with Sizzle to stop matching on the DOM properties, so this will all be happily consistent again.
You will probably also notice here that the first test case will behave differently in IE6/7 because they run through Sizzle.