[heycam/webidl] record<> converted to a JS value should use a null prototype (#904)

Currently records get [converted to a JS value](https://heycam.github.io/webidl/#es-record) with `%Object.prototype%` as their [[Prototype]].

We should instead consider using a null prototype. This avoids false positives where it appears that properties like `toString`, `valueOf`, etc. are members of the record.

This also matches some Ecma-262 precedent a bit better: [RegExp's `exec()` method](https://tc39.es/ecma262/#sec-regexpbuiltinexec) returns a null-prototype "record" for its `groups` property (step 24.a). Indeed, the case that is prompting this issue is the desire to add a similar `groups` property for [service worker scope pattern matching](https://github.com/wanderview/service-worker-scope-pattern-matching/blob/master/explainer.md).

With regard to compatibility: most records in specs are used in input position (e.g. as parameters, or as parts of dictionaries that are themselves used as parameters). The following are the ones I found in output position:

- A couple in webrtc-stats: [1](https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats), [2]https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats)
- As the result of toJSON() for [PushSubscription](https://w3c.github.io/push-api/#dom-pushsubscription)

I'm unsure whether this change is good for those cases. Traditionally, objects returned by toJSON() do not have null-prototype. Hmm.

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

Received on Monday, 3 August 2020 16:18:45 UTC