Not really, right? You can still modify and re-place nodes that have
been removed from the dom, but not on nodes that have been destroyed.

<div id="bar"><p>hi</p><p>there</p></div>

var ps = $("#bar p").remove();
$("#bar").html("<p>hmm</p>");
ps.appendTo("#bar")

or some such.

Regards,
Peter


John Resig wrote:
> Well, if you're arguing that you might as well argue that .remove()
> should return an empty set - since the elements are no longer in the
> document.
>
> --John
>
>
> On Tue, Aug 18, 2009 at 10:30 AM, Andrea Giammarchi
> <andrea.giammar...@gmail.com <mailto:andrea.giammar...@gmail.com>> wrote:
>
>     Actually, me and phiggins were looking at TaskSpeed bench and he
>     spotted an error in my Pure DOM which was basically the reason we
>     realized every single test there was wrong.
>
>     let's do an example. My document has 3 divs:
>
>     '<div><div></div></div><div></div>'
>
>     one is nested ... now I do this:
>
>     $("div").html("leak?").length; // which is 3
>
>     I am not sure if all libraries are managing the case in the same
>     way but I would not leave that div wrapped in that variable.
>
>     If jQuery object related search is saved, it could be useful to
>     re-search it after each operation otherwise problems like this
>     will be truly common and leaks more probable than pure DOM
>     manipulation.
>
>     That test for example is now:
>
>     var div = document.getElementsByTagName("div"), i = 0;
>     while(div[i])
>         div[i++].innerHTML = "leak?";
>     return i;
>
>     because getElementsByTagName is live and I do not want to trap
>     anything.
>
>     Makes sense?
>
>
>
>
>     On Tue, Aug 18, 2009 at 1:40 PM, John Resig <jere...@gmail.com
>     <mailto:jere...@gmail.com>> wrote:
>
>         Well, you could just manipulate this[0], this[1], etc.
>         directly - but it's strongly preferred that you return the new
>         result with pushStack (as you've done) since that conforms
>         with the typical way of constructing jQuery methods and plugins.
>
>         --John
>
>
>
>         On Mon, Aug 17, 2009 at 3:46 PM, jeanph01 <jeanp...@gmail.com
>         <mailto:jeanp...@gmail.com>> wrote:
>
>
>             Hi!
>
>             I'm creating a jquery plugin that alter an object to
>             remove duplicates
>             in it. My problem is that a variable that access the old
>             selector
>             result does not contain the same elements that it would
>             have contained
>             if it would have been executed after the duplicates removal.
>             To illustrate :
>
>             var v = $('div);   // 150 objects
>             v.removeDuplicate();   // remove 10 duplicates
>             // here v still point to 150 objects
>
>
>
>             Here is my plugin :
>
>             jQuery.fn.__sort = function() {
>                return this.pushStack([].sort.apply(this, arguments), []);
>             };
>
>             jQuery.fn.sort = function(func) {
>                function internalSort(a,b){
>                    var compA = $(a).text();
>                    var compB = $(b).text();
>                    return (compA <> compB) ? 1 : 0;
>                }
>                if (!$.isFunction(func)) {
>                    func = internalSort;
>                }
>                return this.__sort(func);
>             };
>
>             jQuery.fn.removeDuplicate = function() {
>                var that = $(this).sort();
>
>                $(this).each(function() {
>                    var pos = that.index($(this));
>                    var next = that.eq(pos+1);
>                    var eq = (next.text() === $(this).text());
>
>                    if (eq) { next.remove();}
>                });
>
>                // enable chaining, updating selector
>                return $($(this).selector);
>             };
>
>
>             The only solution I found is to return $(this) with an updated
>             selector. But I would have had to remember to update the
>             content of my
>             variable before calling the plugin.
>             ex:
>             v = v.removeDuplicates();
>
>             Can I update $(this) from within removeDuplicate() ??
>
>             Thank you
>
>             note: I posted this on the jQuery Plugins discussion put
>             it seems
>             dead, or full of spam.
>
>
>
>
>
>
>
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to