Side navigation
#12121 closed feature (duplicate)
Opened July 22, 2012 10:11AM UTC
Closed July 22, 2012 04:01PM UTC
Last modified July 22, 2012 04:01PM UTC
Inconsistency of .end() with respect to .after()
Reported by: | anonymous | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | git |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
.after()
only changes the stack if the first element in the set is disconnected. This is unfortunate, because .end()
cannot be used with the same result if .after()
is called on an ''empty'' set vs a ''non-empty'' set. You don't always know whether there are elements in the set, and more importantly, it should not matter.
Fiddle: http://jsfiddle.net/3qqXG/
The second div doesn't turn red because it doesn't have any children. The fiddle is contrived, of course, but in real cases you don't know whether there are any children - I'd expect both .end()
calls to select the div again.
I did note that the docs state that .after()
acts differently on a set of disconnected nodes. However, jQuery thinks an empty set is disconnected as well, causing this issue.