Ticket #7500 (closed bug: fixed)
attr() fails for non DOM element nodes
| Reported by: | jitter | Owned by: | jitter |
|---|---|---|---|
| Priority: | blocker | Milestone: | 1.5 |
| Component: | attributes | Version: | 1.4.4 |
| Keywords: | regression attr non DOM element | Cc: | |
| Blocking: | Blocked by: |
Description
With the changes for 1.4.3 a regression was introduced which prevented the use of attr() on anything but DOM element nodes (where nodeType is 1) see #7451 and the fix in 1.4.4 commit #a64dc0
But now attr(name) and attr(name, value) fails in various circumstances.
test case switch from version 1.4.2 to 1.4.3 to 1.4.4 to see how the behavior changed from working, to partially working to breaking with exceptions.
Change History
comment:2 Changed 3 years ago by addyosmani
- Keywords attr non DOM element nodes added
- Priority changed from undecided to low
- Status changed from new to open
- Component changed from unfiled to attributes
comment:4 Changed 3 years ago by rwaldron
- Priority changed from low to blocker
- Milestone changed from 1.5 to 1.4.5
Addy, I'm gonna change this to a blocker until we get a consensus on the behaviour regression.
comment:10 Changed 3 years ago by rwaldron
@jitter - weird, I don't remember doing that at all... But check this out: I DID post this... 28 hours ago: http://bugs.jquery.com/ticket/7582
comment:12 Changed 3 years ago by snover
comment:13 Changed 3 years ago by jitter
#7591 is a duplicate of this ticket.
comment:14 Changed 3 years ago by rwaldron
#7605 is a duplicate of this ticket.
comment:15 Changed 3 years ago by rwaldron
#7665 is a duplicate of this ticket.
comment:16 Changed 3 years ago by jitter
#7503 is a duplicate of this ticket.
comment:17 Changed 3 years ago by john
- Status changed from assigned to closed
- Resolution set to fixed
Landed
comment:18 Changed 2 years ago by jitter
- Milestone changed from 1.4.5 to 1.5
Move fixed tickets to appropriate milestone
comment:19 Changed 2 years ago by shepik
The bug reappeared again 1.5.2: everything ok 1.6.0: Getting attribute foo failed for node of type plainjsobject elem.getAttribute is not a function
comment:20 Changed 2 years ago by timmywil
As the docs for http://api.jquery.com/attr states, do not use attr on the document or plain objects. http://api.jquery.com/prop will work instead, but for the document I suggest attaching data with http://api.jquery.com/data unless property manipulation is necessary.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

pull request
There is much noise from whitespace changes use diff -w to see the what's really going on