Skip to content

Commit 28b0cc3

Browse files
authored
Rewrite the ShadowRealm constructor with InitializeHostDefinedRealm (#409)
The current prose no longer works after tc39/ecma262#3139.
1 parent 4c88d76 commit 28b0cc3

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"watch": "npm run build -- --watch"
3030
},
3131
"devDependencies": {
32-
"@tc39/ecma262-biblio": "=2.1.2719",
33-
"ecmarkup": "^18.0.0"
32+
"@tc39/ecma262-biblio": "=2.1.2778",
33+
"ecmarkup": "^19.1.0"
3434
}
3535
}

spec.html

+7-9
Original file line numberDiff line numberDiff line change
@@ -472,16 +472,14 @@ <h1>ShadowRealm ( )</h1>
472472
<emu-alg>
473473
1. If NewTarget is *undefined*, throw a *TypeError* exception.
474474
1. Let _O_ be ? OrdinaryCreateFromConstructor(NewTarget, *"%ShadowRealm.prototype%"*, « [[ShadowRealm]], [[ExecutionContext]] »).
475-
1. Let _realmRec_ be CreateRealm().
475+
1. Let _callerContext_ be the running execution context.
476+
1. Perform ? InitializeHostDefinedRealm().
477+
1. Let _innerContext_ be the running execution context.
478+
1. Remove _innerContext_ from the execution context stack and restore _callerContext_ as the running execution context.
479+
1. Set _O_.[[ExecutionContext]] to _innerContext_.
480+
1. Let _realmRec_ be the Realm of _innerContext_.
476481
1. Set _O_.[[ShadowRealm]] to _realmRec_.
477-
1. Let _context_ be a new execution context.
478-
1. Set the Function of _context_ to *null*.
479-
1. Set the Realm of _context_ to _realmRec_.
480-
1. Set the ScriptOrModule of _context_ to *null*.
481-
1. Set _O_.[[ExecutionContext]] to _context_.
482-
1. Perform SetRealmGlobalObject(_realmRec_, *undefined*, *undefined*).
483-
1. Perform ? SetDefaultGlobalBindings(_O_.[[ShadowRealm]]).
484-
1. Perform ? HostInitializeShadowRealm(_O_.[[ShadowRealm]]).
482+
1. Perform ? HostInitializeShadowRealm(_realmRec_).
485483
1. Return _O_.
486484
</emu-alg>
487485
</emu-clause>

0 commit comments

Comments
 (0)