Skip to content

Define "usual constructor steps" #797

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

Merged
merged 5 commits into from
Sep 24, 2019
Merged
Changes from all commits
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
14 changes: 13 additions & 1 deletion index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -11126,13 +11126,25 @@ and is described in more detail in [[#interface-prototype-object]].
Note: Since an [=interface object=] is a [=function object=]
the <code>typeof</code> operator will return "function" when applied to an interface object.

An interface may have <dfn export>overridden constructor steps</dfn>, which can
change the behavior of the [=interface object=] when called or constructed. By
default interfaces do not have such steps.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a warning like we have a few already for legacy features, saying something like

In general, constructors are described by defining a [=constructor operation=] and its behavior.
The [=overridden constructor steps=] are used only for more complicated situations.
Editors who wish to use this feature are strongly advised to discuss this by filing an issue before proceeding.

<p class="advisement">
In general, constructors are described by defining a [=constructor operation=] and its behavior.
The [=overridden constructor steps=] are used only for more complicated situations.
Editors who wish to use this feature are strongly advised to discuss this by
<a href="https://github.com/heycam/webidl/issues/new?title=Intent%20to%20use%20constructor%20steps">filing an issue</a> before proceeding.
</p>

<div algorithm>

The [=interface object=] for a given [=interface=] |I|
with [=identifier=] |id| and in [=Realm=] |realm|
is <dfn lt="create an interface object">created</dfn> as follows:

1. Let |steps| be the following steps:
1. Let |steps| be |I|'s [=overriden constructor steps=] if they exist, or
the following steps otherwise:
1. If |I| was not declared with a [=constructor operation=],
then [=ECMAScript/throw=] a {{ECMAScript/TypeError}}.
1. If {{NewTarget}} is <emu-val>undefined</emu-val>, then
Copy link
Member

Choose a reason for hiding this comment

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

Should we keep the first two steps, even when overriding the rest of the algorithm?

Maybe also the last four steps?

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 guess that would work for [HTMLConstructor], although it feels cleaner to just have a general primitive that replaces the whole thing.

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'll keep it like this for now, but we can refactor later if you think it's much better.

Expand Down