OpenLayers OpenLayers

Ticket #1063 (closed bug: fixed)

Opened 1 year ago

Last modified 1 year ago

applyDefaults doesn't handle toString and clobbers null

Reported by: tschaub Assigned to:
Priority: minor Milestone: 2.6 Release
Component: Util Version: 2.5 RC5
Keywords: Cc:
State:

Description

There are a few issues with the Util.applyDefaults function.

1. Since toString is always non-null, it doesn't correctly apply a custom toString property from one object to another.

2. Though the docs say "copies any keys that don't exist from another hashtable," an object with a property set to null will be clobbered. I think checking if a property is undefined is closer to checking whether or not it exists (hasOwnProperty doesn't work in Safari).

3. IE (still) doesn't iterate over the toString property of an object. This means we've got to explicitly check for this property (using hasOwnProperty) to apply any custom value from one object to another.

Attachments

defaults.patch (2.6 kB) - added by tschaub on 10/05/07 00:51:25.
work with toString and null property in applyDefaults

Change History

10/05/07 00:51:25 changed by tschaub

  • attachment defaults.patch added.

work with toString and null property in applyDefaults

10/05/07 00:59:25 changed by tschaub

  • keywords set to review.

Patch fixes these issues and tests prevent regression.

All tests pass in IE and FF. Please review.

11/21/07 10:20:12 changed by crschmidt

  • keywords changed from review to commit.

Looks fine. Please commit.

11/26/07 18:34:52 changed by tschaub

  • keywords deleted.
  • status changed from new to closed.
  • resolution set to fixed.

(In [5280]) applyDefaults now respects null - if you want to override a property with applyDefaults, set it to undefined first - applyDefaults also now correctly applies a custom toString method (closes #1063).