This was an intentional change. We found that when doing a deep extend
on non-objects (and I mean that in the "plain object" and "plain
array" sense) a lot of unexpected behavior was encountered. We only
deep extend "plain object"s and "plain array"s now (those that match
jQuery.isPlainObject or jQuery.isArray) any other objects are left
alone and that's helped to resolve a number of bizarre issues.

I don't feel as if it's inconsistent between jQuery.extend(fn, obj)
and deep extending - in the case of deep extending there are many
different possible types of objects that could be extended in
inappropriate ways but in the case of jQuery.extend(fn, obj) you're
being very explicit: You're asking to absolutely extend what's being
passed in.

Regardless, I'm making a note of it in the documentation and in the
release notes too.

--John



On Tue, Jan 12, 2010 at 5:39 PM, Nathan Bubna <nbu...@gmail.com> wrote:
> Looks like the new $.extend implementation doesn't let you recursively
> extend a function anymore:
>
> // create function w/properties
> var T = $.test = function() { alert(T.prop ? 'good' : 'bad'); };
> $.extend(T, { prop: false });
>
> // elsewhere, do deep configuration
> $.extend(true, $, {
>    test: {
>        prop: true
>    }
> });
>
> // uh oh!
> console.log($.test);
> $.test();
>
> I often use this pattern (func w/props) to reduce conceptual area and
> namespace clutter.  I can work around this by directly manipulating
> the properties ($.test.prop = true), but that becomes quite unwieldy
> given the number of properties and the way i pass config objects
> around.
>
> In either case, it seems inconsistent to allow functions to be
> extended directly ($.extend($.test, {prop:true})), but not when doing
> a deep, recursive extend call.  Was this an intended change or have i
> found a bug?
>
> --
> 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=en.
>
>
>
>
-- 
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=en.


Reply via email to