http://dev.jquery.com/ticket/5494
I am sorry if I had hurt someone, it wasn't in my intention. That munged code was there a quite long time, and during reporting it, my mood was going a little worse. On Nov 11, 3:22 pm, John Resig <jere...@gmail.com> wrote: > Ah yes, I see your point now. It looks like this may have gotten > munged in the overhaul done by Yehuda. > > If you want to make a patch with some good test cases I'll happily land it. > > --John > > On Wed, Nov 11, 2009 at 3:27 AM, Robert Katić <robert.ka...@gmail.com> wrote: > > Ah, yes, since options.nodes was already defined before extending, it > > will not become jQuery("#content") (with all jQuery methods copied > > inside itself), but something between jQuery("div") and jQuery > > ("#content") (with all jQuery methods copied inside itself). Even > > worse. > > > I have to suppose that the author was drunk when he was writing it. :) > > > Am I missing something? > > > On Nov 11, 8:16 am, Robert Katić <robert.ka...@gmail.com> wrote: > >> I don't get your point. I am talking about what is extended > >> recursively, not what is passed as argument. > > >> If you have something like this: > > >> var options = { > >> nodes: jQuery("div"), > >> num: 4, > >> date: new Date > > >> }; > > >> jQuery.extend(true, options, { > >> nodes: jQuery("#content"), > >> num: new Number(5), > >> date: new Date > > >> }); > > >> then options.node would be the same jQuery("#content") object but now > >> with all jQuery methods copied inside itself, options.num will remain > >> 4, options.date remain unchanged. > > >> I think this behavior is not what someone would expect (I hope). > > >> On Nov 11, 5:09 am, John Resig <jere...@gmail.com> wrote: > > >> > If someone wants to pass in a random object to be extended we won't > >> > stop them. So yeah, someone could do: > > >> > jQuery.extend([1,2], [3]) and get [3,2] as a result - not sure why you > >> > would want to, though. I can't think of a reason to explicitly prevent > >> > this behavior, at least. > > >> > (On a related note I've renamed isObject to isObjectLiteral.) > > >> > --John > > >> > On Tue, Nov 10, 2009 at 9:10 PM, Robert Katić <robert.ka...@gmail.com> > >> > wrote: > >> > > Wat a hell is going here? > > >> > > // Recurse if we're merging object values > >> > > if ( deep && copy && typeof copy === "object" && !copy.nodeType ) { > >> > > var clone; > > >> > > if ( src ) { > >> > > clone = src; > >> > > } else if ( jQuery.isArray(copy) ) { > >> > > clone = []; > >> > > } else if ( jQuery.isObject(copy) ) { > >> > > clone = {}; > >> > > } else { > >> > > clone = copy; > >> > > } > > >> > > // Never move original objects, clone them > >> > > target[ name ] = jQuery.extend( deep, clone, copy ); > > >> > > You are going to extend with any object including a Date, a String, a > >> > > Number... (ah yes, excluding nodes). > > >> > > You are going to extend (with) arrays? [1,2] and [4] to obtain [4,2]. > >> > > Really? > > >> > > If an object is not an array nor an object literal then extend object > >> > > with itself??? > > >> > > The only things to extend recursively are objects literals to me: > > >> > > if ( deep && copy && jQuery.isObject(copy) && (!src || jQuery.isObject > >> > > (src)) ) { > >> > > target[ name ] = jQuery.extend( deep, src || {}, copy ); > >> > > } > > >> > > Am I loosing my mind? :) > > >> > > -- > > >> > > You received this message because you are subscribed to the Google > >> > > Groups "jQuery Development" group. > >> > > To post to this group, send email to jquery-...@googlegroups.com. > >> > > To unsubscribe from this group, send email to > >> > > jquery-dev+unsubscr...@googlegroups.com. > >> > > For more options, visit this group > >> > > athttp://groups.google.com/group/jquery-dev?hl=. > > > -- > > > You received this message because you are subscribed to the Google Groups > > "jQuery Development" group. > > To post to this group, send email to jquery-...@googlegroups.com. > > To unsubscribe from this group, send email to > > jquery-dev+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/jquery-dev?hl=. -- You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-...@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=.