Internationalization: null as options property

Norbert Lindenberg ecmascript at norbertlindenberg.com
Fri Aug 3 14:29:14 PDT 2012


A null value in a property of the options arguments in the ECMAScript Internationalization API is currently special-cased and treated as if it were undefined, leading to default values to be applied. This probably crept in based on examples in some libraries that treat any falsy value in options properties like undefined.

The API expects booleans, strings, and numbers in these properties, not objects (although objects will be coerced to the expected types). It seems best practice is to use null only where objects are expected, so it shouldn't be used here.

I'd like to remove the special case handling, that is, delete "or null" from steps 2 of sections 9.2.9 and 9.2.10 of the spec. Coercion would be applied instead depending on the expected type:
- String: coerced to "null", which will result in RangeError exceptions being thrown.
- Boolean: coerced to false.
- Number: coerced to +0, which may result in RangeError exceptions being thrown.

Any objections?

Thanks,
Norbert



More information about the es-discuss mailing list