[jQuery] Stupid question: what is the return value of replaceWith good for?
While I love most things in jQuery, one thing I don't get is
replaceWith. This method returns the object you just replaced, which
as far as I can see is 100% worthless, rather than the the object
you're replacing it with. If you do:
$.(someHtmlElement).replaceWith("<div>my div</div>");
There is no way whatsoever (as far as I can tell at least) to access
"<div>my div</div>" after the replacement. You can access
someHtmlElement, but that's not very helpful; if you're replacing it,
you probably don't care about it anymore.
I read on some other threat that this hearkens back to an early jQuery
design philosophy issue. However, I have a hard time believing such
an otherwise awesome library would make such a (seemingly) obviously
poor design choice just for philosophy, so I have to ask:
Am I just missing some obvious case where it would actually be useful
to get the replaced element back? Or am I perhaps instead missing
some obvious way to access the replacement element?
Any explanation of this problematic (to me at least) behavior would be
appreciated.