Quantcast
Channel: jQuery: Ticket #12120: Inconsistency of .end() with respect to .after()
Viewing all articles
Browse latest Browse all 34

Article 10

$
0
0

Thanks for sharing your thoughts. I believe that never pushing the stack would be the most consistent, given that e.g. .append exhibits the same behaviour.

It should be noted that alot of jQuery's functions are actually inconsistent with respect to pushing the stack. For example, appendTo etc. always push the stack except for specific cases (see the source). This causes a different stack between:

$("p").appendTo("body"); prevObject: empty set $("<p>").appendTo("body"); prevObject: undefined

Also, it should be noted that doing disconnected.after("foo").end() still includes the "foo" text node. This is because jQuery.merge modifies the current set (this) and returns the modified set. That set is passed to pushStack which causes two same sets on the stack.

Here's a jsFiddle illustrating append vs after: http://jsfiddle.net/3qqXG/5/


Viewing all articles
Browse latest Browse all 34

Trending Articles