Skip to content

Commit

Permalink
Editorial: Return created Realm from InitializeHostDefinedRealm
Browse files Browse the repository at this point in the history
This AO is not being used in ECMA-262 directly, but from real-world
experience implementing & using is as-is I can say that having to pull
the Realm out of the running execution context is somewhat awkward.

This change is backwards compatible with how the HTML spec uses the AO,
but this would allow simplifying the following:

1. Perform InitializeHostDefinedRealm() with the provided customizations
   for creating the global object and the global this binding.
2. Let realm execution context be the running JavaScript execution
   context.
3. Remove realm execution context from the JavaScript execution context
   stack.
4. Let realm be realm execution context's Realm component.

to

1. Let realm be InitializeHostDefinedRealm() with the provided
   customizations for creating the global object and the global this
   binding.
2. Let realm execution context be the running JavaScript execution
   context.
3. Remove realm execution context from the JavaScript execution context
   stack.

(https://html.spec.whatwg.org/#creating-a-new-javascript-realm)

For hosts that don't have HTML's requirement of removing the running
execution context, it becomes a simple:

1. Let realm be InitializeHostDefinedRealm().
  • Loading branch information
linusg committed Jan 27, 2024
1 parent 3290694 commit da96f27
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -12086,7 +12086,7 @@ <h1>
</emu-clause>

<emu-clause id="sec-initializehostdefinedrealm" type="abstract operation">
<h1>InitializeHostDefinedRealm ( ): either a normal completion containing ~unused~ or a throw completion</h1>
<h1>InitializeHostDefinedRealm ( ): either a normal completion containing a Realm Record or a throw completion</h1>
<dl class="header">
</dl>

Expand All @@ -12102,7 +12102,7 @@ <h1>InitializeHostDefinedRealm ( ): either a normal completion containing ~unuse
1. Perform SetRealmGlobalObject(_realm_, _global_, _thisValue_).
1. Let _globalObj_ be ? SetDefaultGlobalBindings(_realm_).
1. Create any host-defined global object properties on _globalObj_.
1. Return ~unused~.
1. Return realm.
</emu-alg>
</emu-clause>

Expand Down

0 comments on commit da96f27

Please sign in to comment.