-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do records (record<>s) purposefully throw on any object with an enumerable Symbol-named property? #294
Comments
Oh, and as a data point, Gecko current equivalent (MozMap) skips Symbol-named props instead. |
I didn't consider the case of Symbol-named properties. The existing implementation in Mozilla is a good argument to allow-and-ignore Symbol-named properties. On the other hand, we meant folks to create the ES object specifically to pass into the |
Let's call this by-design :) |
@domenic Do we have tests for this by-design behavior? |
Probably not... let's reopen until we can be sure. |
I'm going to write some tests in https://bugzilla.mozilla.org/show_bug.cgi?id=1366032 fwiw. |
But note that right now no browsers throw here, so it could be a compat risk.... We'll see. |
In particular, Chrome's handling of this right now seems to match Firefox's: the symbol-named props are ignored. |
And Safari's matches in terms of not throwing, though not some of the other MOP details. |
I purposefully followed Gecko and what was discussed here when adding support for records in Blink. In any case, record support landed in M59, which is still in beta so I guess it's still easier to change the behavior if necessary. |
I've filed https://bugs.chromium.org/p/chromium/issues/detail?id=724481 to keep track of this in Blink. |
Is this consistent with ECMAScript? I'm not an expert, but neither of 7.3.21EnumerableOwnProperties nor 13.7.5.15EnumerateObjectProperties seem throwing an exception. Probably I should look at different places. I'm just wondering if it's consistent with ECMAScript or not, and if not, we can update the spec instead of the implementations. |
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 (and 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 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 |
Thanks for the explanation. Makes sense. |
We were previously skipping all symbols when calling GetOwnPropertyNames() due to whatwg/webidl#294 being unresolved at the time the code was written, as well as to maintain compatibility with Gecko, which did the same at the time. That GitHub issue has since been resolved: enumerable symbols should not be skipped but rather just throw a TypeError when a string conversion function is called on it. Gecko is also being updated, and this CL adjusts our code accordingly. The new tests being added to headers-record.html come from Boris Zbarsky <bzbarsky@mit.edu> and were originally written in https://bugzilla.mozilla.org/show_bug.cgi?id=1366032. They are being included here mostly to both help test the CL, as I believe they will be landed in Gecko and synced to web-platform-tests before this CL lands and we end up upstreaming the changes. While here, remove a duplicate test case in NativeValueTraitsImplTest. BUG=724481 R=bashi@chromium.org,haraken@chromium.org,yukishiino@chromium.org Review-Url: https://codereview.chromium.org/2900743002 Cr-Commit-Position: refs/heads/master@{#473905}
We were previously skipping all symbols when calling GetOwnPropertyNames() due to whatwg/webidl#294 being unresolved at the time the code was written, as well as to maintain compatibility with Gecko, which did the same at the time. That GitHub issue has since been resolved: enumerable symbols should not be skipped but rather just throw a TypeError when a string conversion function is called on it. Gecko is also being updated, and this CL adjusts our code accordingly. The new tests being added to headers-record.html come from Boris Zbarsky <bzbarsky@mit.edu> and were originally written in https://bugzilla.mozilla.org/show_bug.cgi?id=1366032. They are being included here mostly to both help test the CL, as I believe they will be landed in Gecko and synced to web-platform-tests before this CL lands and we end up upstreaming the changes. While here, remove a duplicate test case in NativeValueTraitsImplTest. BUG=724481 R=bashi@chromium.org,haraken@chromium.org,yukishiino@chromium.org Review-Url: https://codereview.chromium.org/2900743002 Cr-Commit-Position: refs/heads/master@{#473905}
We were previously skipping all symbols when calling GetOwnPropertyNames() due to whatwg/webidl#294 being unresolved at the time the code was written, as well as to maintain compatibility with Gecko, which did the same at the time. That GitHub issue has since been resolved: enumerable symbols should not be skipped but rather just throw a TypeError when a string conversion function is called on it. Gecko is also being updated, and this CL adjusts our code accordingly. The new tests being added to headers-record.html come from Boris Zbarsky <bzbarsky@mit.edu> and were originally written in https://bugzilla.mozilla.org/show_bug.cgi?id=1366032. They are being included here mostly to both help test the CL, as I believe they will be landed in Gecko and synced to web-platform-tests before this CL lands and we end up upstreaming the changes. While here, remove a duplicate test case in NativeValueTraitsImplTest. BUG=724481 R=bashi@chromium.org,haraken@chromium.org,yukishiino@chromium.org Review-Url: https://codereview.chromium.org/2900743002 Cr-Commit-Position: refs/heads/master@{#473905}
Walking through https://heycam.github.io/webidl/#es-to-record for an object with an enumerable Symbol-named property, what happens?
Is this by-design?
// cc @jyasskin @domenic @tobie @heycam @annevk
The text was updated successfully, but these errors were encountered: