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 globalThis #702

Merged
merged 1 commit into from
Oct 2, 2019
Merged

Normative: add globalThis #702

merged 1 commit into from
Oct 2, 2019

Conversation

ljharb
Copy link
Member

@ljharb ljharb commented Sep 29, 2016

  • Adds intrinsic %GlobalThisValue%
  • Sets it in SetRealmGlobalObject
  • Adds global name globalThis

Per tc39/proposal-global#12

@ljharb ljharb mentioned this pull request Sep 29, 2016
31 tasks
@ljharb
Copy link
Member Author

ljharb commented Sep 29, 2016

Note: do not merge until stage 4 - an approved PR is now a pre-stage-4 requirement.

@bterlson bterlson added the pending stage 4 This proposal has not yet achieved stage 4, but may otherwise be ready to merge. label Sep 29, 2016
@littledan
Copy link
Member

For context, the name global has web compatibility issues. @ljharb is working on switching to a new name. This patch will not land in its current state.

@ljharb ljharb self-assigned this Mar 5, 2018
@ljharb ljharb added the proposal This is related to a specific proposal, and will be closed/merged when the proposal reaches stage 4. label Mar 21, 2018
@ljharb ljharb added the normative change Affects behavior required to correctly evaluate some ECMAScript source text label Jul 25, 2018
ljharb added a commit to ljharb/ecma262 that referenced this pull request Sep 12, 2018
 - Adds intrinsic `%GlobalThisValue%`
 - Sets it in `SetRealmGlobalObject`
 - Adds global name `globalThis`

Per tc39/proposal-global#12
@ljharb ljharb changed the title Normative: add global Normative: add globalThis Sep 12, 2018
@ljharb ljharb requested review from bterlson, bmeck and a team September 12, 2018 18:59
spec.html Outdated Show resolved Hide resolved
ljharb added a commit to ljharb/ecma262 that referenced this pull request Sep 12, 2018
 - Adds intrinsic `%GlobalThisValue%`
 - Sets it in `SetRealmGlobalObject`
 - Adds global name `globalThis`

Per tc39/proposal-global#12
spec.html Outdated Show resolved Hide resolved
@domenic
Copy link
Member

domenic commented Mar 7, 2019

FYI to TC39: there is an interesting question of what globalThis should be for discarded windows. (I.e. those whose parent iframe was .remove()ed, or whose window was .close()ed.) It appears Chrome/Safari/Firefox all continue to return the global object in that case. However, for self/window/frames, Safari returns null instead.

@annevk filed a bug on Safari to align their window/self/frames with Chrome/Firefox, and also with their own globalThis implementation.

So, there is no action here for TC39, but I thought it'd be interesting to know.

ljharb added a commit to ljharb/ecma262 that referenced this pull request Mar 8, 2019
 - Adds intrinsic `%GlobalThisValue%`
 - Sets it in `SetRealmGlobalObject`
 - Adds global name `globalThis`

Per tc39/proposal-global#12
ljharb added a commit to ljharb/ecma262 that referenced this pull request Mar 9, 2019
 - Adds intrinsic `%GlobalThisValue%`
 - Sets it in `SetRealmGlobalObject`
 - Adds global name `globalThis`

Per tc39/proposal-global#12
spec.html Outdated
@@ -23338,6 +23337,12 @@ <h1>The Global Object</h1>
<emu-clause id="sec-value-properties-of-the-global-object">
<h1>Value Properties of the Global Object</h1>

<emu-clause id="sec-global-this">
<h1>globalThis</h1>
<p>The initial value of `globalThis` is the value of the field of (the value of the field of the Realm Record named [[GlobalEnv]]) named [[GlobalThisValue]].
Copy link
Member Author

Choose a reason for hiding this comment

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

this phrasing is super awkward. Any recommendations of how to do this cleaner without algorithm steps?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
<p>The initial value of `globalThis` is the value of the field of (the value of the field of the Realm Record named [[GlobalEnv]]) named [[GlobalThisValue]].
<p>The initial value of the `globalThis` property of the global object of a realm _realm_ is the value of `_realm_.[[GlobalEnv]].[[GlobalThisValue]]`.</p>

That fudges the distinction between a realm and a Realm Record, so you could say ... of a realm represented by the Realm Record _realm_ ..., but I'm doubtful that'd be better.

spec.html Outdated Show resolved Hide resolved
ljharb added a commit to ljharb/ecma262 that referenced this pull request Mar 11, 2019
 - Adds intrinsic `%GlobalThisValue%`
 - Sets it in `SetRealmGlobalObject`
 - Adds global name `globalThis`

Per tc39/proposal-global#12
ljharb added a commit to ljharb/ecma262 that referenced this pull request Aug 7, 2019
 - Adds intrinsic `%GlobalThisValue%`
 - Sets it in `SetRealmGlobalObject`
 - Adds global name `globalThis`

Per tc39/proposal-global#12
@ljharb ljharb requested a review from jmdyck September 23, 2019 05:52
@ljharb ljharb self-assigned this Sep 23, 2019
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
ljharb added a commit to ljharb/ecma262 that referenced this pull request Sep 26, 2019
 - Adds intrinsic `%GlobalThisValue%`
 - Sets it in `SetRealmGlobalObject`
 - Adds global name `globalThis`

Per tc39/proposal-global#12
@ljharb ljharb requested a review from jmdyck September 26, 2019 05:58
@ljharb ljharb added has stage 4 This PR represents a proposal that has achieved stage 4, and is ready to merge. and removed pending stage 4 This proposal has not yet achieved stage 4, but may otherwise be ready to merge. labels Oct 1, 2019
ljharb added a commit to ljharb/ecma262 that referenced this pull request Oct 1, 2019
 - Adds intrinsic `%GlobalThisValue%`
 - Sets it in `SetRealmGlobalObject`
 - Adds global name `globalThis`

Per tc39/proposal-global#12
Copy link
Collaborator

@jmdyck jmdyck left a comment

Choose a reason for hiding this comment

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

Looks okay to me.

 - Adds intrinsic `%GlobalThisValue%`
 - Sets it in `SetRealmGlobalObject`
 - Adds global name `globalThis`

Per tc39/proposal-global#12
@ljharb ljharb merged commit 5b01972 into tc39:master Oct 2, 2019
@ljharb ljharb deleted the global branch October 2, 2019 15:14
annevk added a commit to whatwg/html that referenced this pull request Oct 2, 2019
annevk added a commit to whatwg/html that referenced this pull request Oct 16, 2019
Before this change these getters did not account for Window object's browsing context potentially being null, resulting in a conceptual crash.

Language from tc39/ecma262#702.

Tests: web-platform-tests/wpt#15720.

Helps with #4363.
zcorpan pushed a commit to whatwg/html that referenced this pull request Nov 6, 2019
Before this change these getters did not account for Window object's browsing context potentially being null, resulting in a conceptual crash.

Language from tc39/ecma262#702.

Tests: web-platform-tests/wpt#15720.

Helps with #4363.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has stage 4 This PR represents a proposal that has achieved stage 4, and is ready to merge. normative change Affects behavior required to correctly evaluate some ECMAScript source text proposal This is related to a specific proposal, and will be closed/merged when the proposal reaches stage 4.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants