Opened 8 years ago

Closed 5 years ago

#15275 closed task (fixed)

clean up kernel.global, win.global etc.

Reported by: bill Owned by:
Priority: undecided Milestone: 2.0
Component: Core Version: 1.7.2
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by bill)

(in progress ticket based on http://thread.gmane.org/gmane.comp.web.dojo.devel/17548)

dojo.global/kernel.global/win.global in our code are confusingly used to refer to both to a global context, and to the current window. To separate those concepts, possible cleanup includes:


(1) replace non-UI uses of dojo.global/kernel.global/win.global (i.e. usages that aren't assuming that dojo.global refers to a Window object)

For modules that need access to the global context, they can use either this:

define([], function(){
   var global = this;
});

or use kernel.global:

define(["dojo/_base/kernel"], function(kernel){
   var global = kernel.global;
});

The former is preferable since it's simpler, but is a hairline break in backwards compatibility, so maybe should wait for 2.0.


(2) replace UI usages of dojo.global/kernel.global/win.global with win.win

For clarity, make a new variable called win.win that is the Window object associated with win.doc. Update code referencing win.global as a Window to use win.win instead.

Deprecate win.withGlobal() in favor of a method call win.withWindow(). Make both win.withWindow() and win.withDoc() set both win.win and win.doc. The latter requires moving the code in dojo/window::get() to dojo/_base/window, so that win.withDoc() can figure out the window associated w/the specified document.

The other alternative is to get rid of win.withDoc() and win.withGlobal() altogether. Except for a few open issues listed in #15216, they aren't really necessary anymore, although arguably they are convenient in some special cases.

See also #14690 and #15216

Change History (4)

comment:1 Changed 8 years ago by bill

In [28455]:

When win.global is used as a scope for global variables, rather than a reference to the browser's Window object, use kernel.global instead. I'd prefer to use neither but that's an arguable break in backwards compatibility. At least this makes things clearer and in many cases removes the dependency on dojo/_base/window.

Refs #15275 !strict.

comment:2 Changed 8 years ago by bill

Description: modified (diff)

comment:3 Changed 8 years ago by bill

Milestone: tbd2.0

comment:4 Changed 5 years ago by dylan

Component: GeneralCore
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.