Skip to content

Integrate with MakeRealm#12580

Open
annevk wants to merge 5 commits into
mainfrom
annevk/makerealm
Open

Integrate with MakeRealm#12580
annevk wants to merge 5 commits into
mainfrom
annevk/makerealm

Conversation

@annevk

@annevk annevk commented Jun 15, 2026

Copy link
Copy Markdown
Member

Comment thread source Outdated
@annevk

annevk commented Jun 22, 2026

Copy link
Copy Markdown
Member Author

I read through this PR and whatwg/webidl#1608 again and made a few tweaks, but overall I'm happy with the new shape.

Perhaps it's a little odd that MakeRealm ends up returning an execution context rather than a realm as the name suggests, but that seems fine (and was already the case for HTML's create a new realm).

@annevk annevk requested a review from jmdyck June 22, 2026 12:17
@annevk annevk added topic: script integration Better coordination across standards needed labels Jun 22, 2026
Comment thread source Outdated
Comment on lines +117151 to +117152
<var>customizations</var> taking a <span>JavaScript execution context</span> and returning a
tuple of an object (the global object) and an object or null (the global <b>this</b> binding):</p>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The EcmaScript spec doesn't have the concept of a tuple; it's expecting customizations to return a List of two elements. So we could make that change here.

Alternatively, maybe it would simplify things to say that, because customizations now explicitly has access to the realm being created, it can simply assign the two objects to the realm's [[GlobalObject]] and [[GlobalEnv]] fields, and not return anything. MakeRealm, after calling customizations, can detect whether those fields have been set, and if not, set them to their defaults. (First suggested here: tc39/ecma262#3728 (comment), in the first bullet.)

(Note that the HTML and Web IDL specs already refer to [[GlobalObject]] and [[GlobalEnv]], so it's not like this would be breaking some encapsulation.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I can make the change to set those fields instead. That seems nice.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I tried this, but I think it's actually less nice as it would require HTML to also take a dependency on NewGlobalEnvironment to set [[GlobalEnv]] correctly. So for now I'll just update to return a list instead. Let me know if you disagree.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it would require HTML to also take a dependency on NewGlobalEnvironment to set [[GlobalEnv]] correctly.

Hm, yeah. Oh well.

@annevk annevk force-pushed the annevk/makerealm branch from a29f808 to ba9cf92 Compare June 23, 2026 08:11
@annevk annevk force-pushed the annevk/makerealm branch from ba9cf92 to cd40a65 Compare June 23, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration Better coordination across standards needed topic: script

Development

Successfully merging this pull request may close these issues.

4 participants