jQuery 1.3.2 appendTo change breaks our code.

jQuery 1.3.2 appendTo change breaks our code.


I just tried to upgrade to 1.3.2 and have a major issue with the
appendTo change. One paradigm we use is adding functions (and
properties) onto jquery objects with jquery extend. The jquery object
is often returned from a function and then appended into the DOM. For
example, our buttons are created and then returned with methods
attached that are useful for enabling, disabling, setting commands,
etc.
var button = makeNewButton().addClass('TestButton').appendTo(parent);
Later we might want to disable the button with button.disable(). As
of 1.3.2, this is no longer possible as appendTo does not return the
original object. There are plenty of ways to get around this (like
just using end() after almost every appendTo or doing the appendTo in
a second step or overriding appendTo inside the button constructor),
but the change disrupts the expected chainability of jQuery.
Before reading your example in the release notes, I would have
expected this:
<div><p class="test"></div>
<div></div>
as a result of:
<div></div>
<div></div>
<script>
$("<p/>")
.appendTo("div")
.addClass("test");
</script>
The behavior of cloning the original element seems more surprising to
me than it just putting it on the first div it finds. If I really
wanted the expected result, the natural way I would think about it is:
$('div').append($('<p/>').addClass('test'));
As I doubt many people use appendTo as you did in your example and it
breaks jQuery's chainability, I strongly feel that this change should
be reverted.
Thanks,
Jeremy