Bump ;-)
I'd like to second Mark's suggestion. It's more powerful and doesn't
break existing functionality.
Well done, Mark.
Luke
Mark Gibson wrote:
> Hi,
> I'd like to suggest an enhancement to $.extend, to allow extending
> an object from multiple objects.
>
> This will allow a simple way for plugins to have a global set of
> default options:
>
> $.fn.plugin(options) {
> var options = $.extend({}, arguments.callee.defaults, options || {});
> ...
> }
> $.fn.plugin.defaults = { ... }
>
> This extends an empty object with the global defaults and then
> again with the local options. With the existing implementing this would
> have to be done as such:
>
> $.extend($.extend({}, arguments.callee.defaults), options || {});
>
>
> Heres the new $.extend function:
>
> jQuery.extend = jQuery.fn.extend = function(obj) {
> // If no property objects were provided, then we're extending jQuery
> if ( arguments.length == 1 ) {
> var obj = this;
> var a = 0;
> } else {
> var a = 1;
> }
>
> while (a < arguments.length) {
> var prop = arguments[a];
>
> if (prop !== null && prop != undefined) {
> // Extend the base object
> for ( var i in prop ) obj[i] = prop[i];
> }
>
> a++;
> }
>
> // Return the modified object
> return obj;
> };
>
> - Mark Gibson
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/