Bug Tracker

Opened 12 years ago

Closed 12 years ago

#9185 closed bug (invalid)

attr gives an unhandled error when run on a document selection

Reported by: lonesomeday Owned by:
Priority: low Milestone: 1.next
Component: attributes Version: git
Keywords: Cc:
Blocked by: Blocking:

Description

Before jQuery 1.6, it was possible (if silly) to get the properties of the document object using attr(). This functionality has obviously been broken in 1.6. However, it does not fail in a natural way (returning undefined?). It calls getAttribute on the node, which causes a JS error.

jsFiddle example

StackOverflow question

Change History (2)

comment:1 Changed 12 years ago by lonesomeday

Github pull request -- make attr return undefined (as for comment and text nodes).

comment:2 Changed 12 years ago by timmywil

Component: unfiledattributes
Priority: undecidedlow
Resolution: invalid
Status: newclosed

As the docs now state (http://api.jquery.com/attr), attr should not be used on the document or window. It throws an error because these do not and cannot have attributes. Failing silently may not be as helpful.

Note: See TracTickets for help on using tickets.