Re: IDL enumeration & String.prototype.normalize

 On Aug 6, 2013, at 7:59 AM, Anne van Kesteren wrote:

> In IDL not being part of an enumeration throws TypeError. It seems
> String.prototype.normalize uses RangeError. I've no preference as to
> which is better, but it would be good if they were equal.

The argument to String.prototype.noralization is not an enumeration (not an ES concept) but a string.  If the agument can not be converted to a string value, a TypeError is thrown.  If the string value is not within the range of expected values, a RangeError is thrown.  This is all normal ES conventions.

> 
> Also, throughout the platform we typically lowercase enumeration
> constants, e.g. "arraybuffer". I think it would be good for
> String.prototype.normalize to follow that precedent and use "nfc" etc.

The argument values aren't enumeration constants.  They are string values that are the exact the abbreviations used by the Unicode standard to identify normalization forms. 

> 
> (I was a bit surprised to see Unicode normalization exposed here.
> We've been pretty hesitant elsewhere to introduce dependencies on it,
> but I guess at this level it might be okay.)

see http://wiki.ecmascript.org/doku.php?id=strawman:unicode_normalization for the rationale.


Allen


> 
> 
> -- 
> http://annevankesteren.nl/
> 

Received on Tuesday, 6 August 2013 15:33:29 UTC