Ticket #6012 (closed bug: fixed)
.attr uncomatibility between 1.3.x and 1.4.x
| Reported by: | snop | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.4.2 |
| Component: | attributes | Version: | 1.4.1 |
| Keywords: | Attributes | Cc: | |
| Blocking: | Blocked by: |
Description
Hi dev,
in 1.3.x .attr method returned undefined when element didn't exist, but in 1.4.x .attr return null
And this isn't in documentation!
I don't know if it's bug or feature
Change History
comment:1 follow-up: ↓ 2 Changed 3 years ago by john
- Status changed from new to closed
- Resolution set to wontfix
comment:2 in reply to: ↑ 1 Changed 3 years ago by snop
- Status changed from closed to reopened
- Resolution wontfix deleted
Replying to john:
Hard to tell without a specific test case but this was likely done intentionally. Please re-open if you have a specific test case.
Hi John,
it's definitively the bug.
test case is very simple, just test this on the site where is jQuery 1.4 ( #foo element doesn't exist ): $('#foo').val() - return value is undefined and then try $('#foo').attr('value') - return value is null
And then try the same on the site where is jQuery 1.3: $('#foo').val() - return value is undefined and then try $('#foo').attr('value') - return value is undefined
It's inconsistency, because the methods are doing the same, so they must return the same value when domelement doesn't exist.
comment:3 follow-up: ↓ 4 Changed 3 years ago by john
Ah, it wasn't clear that the element didn't exist in this case, I can check in to that.
comment:4 in reply to: ↑ 3 Changed 3 years ago by snop
Replying to john:
Ah, it wasn't clear that the element didn't exist in this case, I can check in to that.
Hi,
ok, John can you add me to the cc pls ? I forgot
I thought, that if I craete ticket, i will added to the CC automatically, this could be changed too.
Thank you
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Hard to tell without a specific test case but this was likely done intentionally. Please re-open if you have a specific test case.