IDL enumeration & String.prototype.normalize

Allen Wirfs-Brock allen at wirfs-brock.com
Tue Aug 6 08:32:53 PDT 2013


 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/
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130806/cffdd690/attachment.html>


More information about the es-discuss mailing list