Bug Tracker

Opened 11 years ago

Closed 11 years ago

#10726 closed bug (fixed)

$(#document).closest('[foo]') throws error in IE

Reported by: cwolves Owned by: timmywil
Priority: low Milestone: None
Component: selector Version:
Keywords: Cc:
Blocked by: Blocking:


Trying to access properties of what I think is a document fragment (nodeName === '#document' ) throws an error in IE:

Object doesn't support property or method 'getAttribute'

The code triggering this is $('iframe').contents().closest('[foo]')

Change History (8)

comment:1 Changed 11 years ago by cwolves


comment:2 Changed 11 years ago by dmethvin

Owner: set to cwolves
Status: newpending

Can you provide a simple reduced test case?

What is the use case for this? Closest is going to look up from the .contents() and that doesn't even seem useful.

comment:3 Changed 11 years ago by cwolves

Status: pendingnew

the $('iframe').contents() piece is coming from a 3rd party plugin. I'm doing $node.closest('[foo]') for a separate purpose, I'm just getting a #document node.

comment:4 Changed 11 years ago by timmywil

Component: unfiledtraversing
Priority: undecidedlow

comment:5 Changed 11 years ago by cwolves

nope, that's a different issue. Don't think it's iframes specifically, just the #document node

Last edited 11 years ago by cwolves (previous) (diff)

comment:6 Changed 11 years ago by timmywil

Owner: changed from cwolves to timmywil
Status: newassigned

@cwolves, I still wouldn't rule it out. .closest uses matchesSelector and calling matchesSelector on a document should be fine. http://jsfiddle.net/timmywil/qa29b/

Calling matchesSelector on an iframe document while trying to access an attribute could be a problem, but I will look into it more.

comment:7 Changed 11 years ago by dmethvin

Component: traversingselector

comment:8 Changed 11 years ago by Timmy Willison

Resolution: fixed
Status: assignedclosed

Fail silently if closest is somehow called on a document. Fixes #10726.

Changeset: 17a26f5bd9b14225248942b876e96545b4c21fb6

Note: See TracTickets for help on using tickets.