Re: [heycam/webidl] Do records (record<>s) purposefully throw on any object with an enumerable Symbol-named property? (#294)

The proper thing to compare with is the public built-in ECMAScript APIs, not the internal spec operations that they use. The only case that seems to accept an arbitrary object with user-supplied keys is [Object.defineProperties](https://tc39.github.io/ecma262/#sec-object.defineproperties) (and `Object.create()`, which reuses the same logic). I suppose maybe [Object.assign](https://tc39.github.io/ecma262/#sec-object.assign) as well.

However, I'm not sure how helpful these comparisons are, because in both cases symbols are a reasonable value. There's no conversion performed, whereas with `record<DOMString, x>`, or for that matter `record<ByteString, x>`, we explicitly need to ensure that all the keys are `DOMString`s (or `ByteString`s).

We have a choice as to how we do this: do we ignore things that do not fit the preferred type, or do we throw? I think throwing is most consistent with other parts of Web IDL. Besides, for the `record<ByteString, x>` case, it would be very weird to ignore keys that could not be converted by a ByteString (e.g. keys with non-ASCII characters); throwing makes sense there. And so I think it also makes sense for keys, like symbols, that cannot be converted to `DOMString`s.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/issues/294#issuecomment-303184581

Received on Monday, 22 May 2017 18:38:41 UTC