Side navigation
#13832 closed bug (wontfix)
Opened April 27, 2013 08:25PM UTC
Closed May 06, 2013 04:22PM UTC
$("html").parent() differs from $("html").parents()
Reported by: | jbedard | Owned by: | |
---|---|---|---|
Priority: | high | Milestone: | 2.next |
Component: | traversing | Version: | 1.9.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
$("html").parent()[0] === document $("html").parents()[0] === undefined
The documentation implies that these methods follow the same definition of "parent" so I would suspect they should treat <html>/document the same?
Looking at the latest 2.0 source... $.dir checks "elem.nodeType !== 9" while traversing and only processes "nodeType === 1", where $.fn.parent only checks "parent.nodeType !== 11". It looks like $.fn.parent should instead check "parent.nodeType === 1"?
Attachments (0)
Change History (4)
Changed April 28, 2013 08:53PM UTC by comment:1
milestone: | None → 2.0.1 |
---|---|
status: | new → open |
Changed April 29, 2013 04:45PM UTC by comment:2
_comment0: | Discussed at the 2013-04-20 meeting, there is concern about changing this because it's been this way (inconsistent) forever. Seems that `.parent()` should always return its parent else we'll think the element is not connected. That makes it more likely we'd change `.parents()` but it would mean that the `document` would be added to the list where it isn't there today. \ → 1367253971776709 |
---|---|
component: | unfiled → traversing |
milestone: | 2.0.1 → 2.next |
priority: | undecided → high |
Discussed at the 2013-04-29 meeting, there is concern about changing this because it's been this way (inconsistent) forever. Seems that .parent()
should always return its parent else we'll think the element is not connected. That makes it more likely we'd change .parents()
but it would mean that the document
would be added to the list where it isn't there today.
Changed April 30, 2013 07:15AM UTC by comment:3
Thanks for the update.
It seems weird returning a non element node since no other traversal methods do, but it does follow the definition of Node.parentNode.
If .parents() changes then .closest() should probably also change. Are there any others?
If .parent() remains as it is that would bring me back to the original reason I found this: $(document).css("...") crashes. I assumed this was because wrapping the document wasn't supported and .parent() shouldn't return it, but if any traversal methods return it then other methods should support it.
Changed May 06, 2013 04:22PM UTC by comment:4
resolution: | → wontfix |
---|---|
status: | open → closed |
Making this a docs ticket, given how long it's been like this it is going to break code to "fix" it.
Agreed, thanks!