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

Normative: Add initializer callback for side effects #165

Merged
merged 7 commits into from
Nov 8, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -821,8 +821,6 @@ <h1>ToElementDescriptor ( _elementObject_ )</h1>
1. Let _kind_ be ? ToString(? Get(_elementObject_, `"kind"`)).
1. If _kind_ is not one of `"method"` or `"field"`, throw a *TypeError* exception.
1. Let _key_ be ? Get(_elementObject_, `"key"`).
1. If _kind_ is `"initializer"`,
1. If _key_ is not *undefined*, throw a *TypeError* exception.
1. If _key_ has a [[PrivateName]] internal slot, set _key_ to _key_.[[PrivateName]].
1. Otherwise, set _key_ to ? ToPropertyKey(_key_).
1. Let _placement_ be ? ToString(? Get(_elementObject_, `"placement"`)).
Expand All @@ -835,7 +833,10 @@ <h1>ToElementDescriptor ( _elementObject_ )</h1>
1. Otherwise,
1. Set _descriptor_ to ? ToPropertyDescriptor(_descriptor_).
1. Let _initializer_ be ? Get(_elementObject_, `"initializer"`).
1. If _kind_ is `"initializer"` and _initializer_ is *undefined*, throw a *TypeError* exception
1. Let _elements_ be ? Get(_elementObject_, `"elements"`).
1. If _kind_ is `"initializer"`,
1. If _key_ is not *undefined*, throw a *TypeError* exception.
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this check happen right after Let _key_ be ? Get(_elementObject_, "key")?

Copy link
Member Author

Choose a reason for hiding this comment

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

I previously tried to sort the validations towards the end, but I can do them mixed inline if you prefer.

Copy link
Member

Choose a reason for hiding this comment

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

I feel like in general we strive to have validations occur as soon as possible, to avoid unnecessary observable behavior.

1. If _elements_ is not *undefined*, throw a *TypeError* exception.
1. If _kind_ is not `"field"` or `"initializer"`,
1. If _initializer_ is not *undefined*, throw a *TypeError* exception.
Expand Down