Skip to content
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

Can no longer create records with symbol keys #93

Merged
merged 1 commit into from
Jul 18, 2022

Conversation

acutmore
Copy link
Contributor

Describe your changes

  • Prevents being able to create records with symbol keys. Fixes Records may only have String keys #77
  • Increases spec compliance of Record.fromEntries by validating the iterator entry by entry

Testing performed
Adds unit tests

- Increases spec compliance of Record.fromEntries

Signed-off-by: Ashley Claymore <[email protected]>
@@ -46,14 +47,17 @@ function createRecordFromObject(value) {
// sort all property names by the order specified by
// the argument's OwnPropertyKeys internal slot
// EnumerableOwnPropertyNames - 7.3.22
const properties = Object.entries(value)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object.entries skips enumerable symbols, whereas the spec throws for them. The new code more closely follows the spec operations.

.flatMap(k => {
const desc = Object.getOwnPropertyDescriptor(value, k);
if (!desc.enumerable) return [];
return [[validateKey(k), validateProperty(value[k])]];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix here: validate and toString the key once

@rricard rricard merged commit bea8da6 into master Jul 18, 2022
@rricard rricard deleted the ac/disallow-symbol-keys branch July 18, 2022 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Records may only have String keys
2 participants