Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#7176 closed bug (invalid)

API Docs: Error in `after`

Reported by: T.J. Crowder Owned by:
Priority: low Milestone: 1.4.3
Component: web Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:


From http://api.jquery.com/after/:

As of jQuery 1.4, .before() and .after() will also work on disconnected DOM nodes. For example, given the following code:
The result is a jQuery set containing a div and a paragraph, in that order.

That's not correct. The jQuery set will still only contain the div; it's just that the paragraph will be added to the DOM after it (but not included in the jQuery object). Test: http://jsbin.com/onoqe4

Change History (4)

comment:1 Changed 13 years ago by addyosmani

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

This isn't par se a jQuery core issue (more a docs one), however we will consider adjusting the language related to this particular API reference on our next review. I've added this to a queue of other API docs we're reviewing and will be closing this ticket so that it can be addressed there instead.

comment:2 Changed 13 years ago by T.J. Crowder

@addyosmani: I didn't see anywhere else to post an API docs bug, and this isn't the only API docs bug here. If there's somewhere else the docs bug should go, by all means point me to it.

Otherwise, this should not be closed. It is a bug. It misleads people relying on the documentation to provide valid information. Until or unless you replace it with a different means of tracking, and ultimately correcting, the bug, closing it is (to put it mildly) contrary to best practice.

comment:3 Changed 13 years ago by dmethvin

The docs are clarifying that .after() works slightly different for disconnected nodes. For example, if you enter this in the url, either here or at jsbin, you'll get the correct answer of 2:


The jsbin test case is *not* the same, it is not on disconnected nodes:


That is selecting a DOM element in the document and then inserting the paragraph after it.

comment:4 Changed 13 years ago by T.J. Crowder

@dmethvin & addyosmani: Yikes, I cannot believe I missed it was talking about disconnected nodes. I mean, it's right there in the text I quoted in this bug report!

With disconnected nodes, it does exactly what it says. Sorry for the hassle.

-- T.J.

Note: See TracTickets for help on using tickets.