This project is archived and is in readonly mode.

#1221 ✓wontfix
Aaron Newton

setOptions and undefined values

Reported by Aaron Newton | May 3rd, 2011 @ 12:31 AM | in 1.4.0 (closed)

One the changes that I'm finding a bit annoying in 1.3 is that setOptions (and, more generally, Object.merge) don't ignore undefined values.

Let's say I'm reading the values from some other property or from an argument or something. I can't do this:

this.setOptions({
 someoption: somevalue
});

and expect that if somevalue is undefined that it'll use the default in the options. Instead I have to do something like:

this.setOptions({
  someoption: somevalue != undefined ? somevalue : this.options.someoption
});

OR

this.setOptions(Object.cleanValues({
 someoption: somevalue
});

I'm pretty sure that MooTools 1.2 didn't behave this way. Any thoughts or opinions here? How about an Object.mergeClean or something like that for doing this for you? Seems silly to iterate over the object twice.

Comments and changes to this ticket

  • Christoph Pojer

    Christoph Pojer May 3rd, 2011 @ 10:44 PM

    • State changed from “new” to “invalid”

    We do not differentiate between null and undefined. If you provide those values in setOptions, they will overwrite the default values (as discussed on GTalk)

  • Aaron Newton

    Aaron Newton May 3rd, 2011 @ 10:44 PM

    • State changed from “invalid” to “wontfix”

    After discussing with Christoph Pojer a bit, I'm going to close this. It's annoying, but there's no real clean solution here.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket

Pages