jQuery: The Write Less, Do More JavaScript Library

Ticket #1236 (closed bug: fixed)

Opened 1 year ago

Last modified 1 year ago

Extend should not die before processing all of its arguments.

Reported by: daemach Assigned to: john
Type: bug Priority: major
Milestone: 1.1.4 Component: core
Version: 1.1.3 Keywords:
Cc: Needs: Review

Description

The $.extend() documentation says:

$.extend( Object target, Object prop1, Object propN ) returns Object Extend one object with one or more others, returning the original, modified, object.

Currently, $.extend dies after hitting a undefined value, even if there are more valid arguments in the list. This is not good behavior. Consider the following:

this.settings = jQuery.extend({}, this.defaults, arguments.options, this.userOptionsFromCookie); // named to illustrate purpose

If I don't need to pass the function any arguments, arguments.options is undefined. I still want user options to modify the defaults however. Rather than using a while != null loop, you should be using a for loop to ensure that all arguments are processed. An argument with an undefined value should be ignored but it shouldn't halt processing.

Attachments

Change History

Changed 1 year ago by john

  • owner set to john
  • version changed from 1.1.2 to 1.1.3
  • milestone changed from 1.1.3 to 1.1.4

Changed 1 year ago by john

  • status changed from new to closed
  • resolution set to fixed

Fixed in SVN rev [2783].

Note: See TracTickets for help on using tickets.