Inconsistency of .end() with respect to .after()
|Reported by:||anonymous||Owned by:|
.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.
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.
Change History (17)
comment:1 Changed 5 years ago by
|Component:||unfiled → manipulation|
|Milestone:||None → 1.8|
|Priority:||undecided → low|
|Status:||new → open|
|Type:||feature → bug|
comment:13 Changed 5 years ago by
|Milestone:||1.8.1 → 1.9|
|Status:||closed → reopened|