Opened 10 years ago

Last modified 7 years ago

#15216 closed task

reduce/eliminate dependence on dojo/_base/window::doc "global" — at Version 3

Reported by: bill Owned by: bill
Priority: undecided Milestone: 1.8
Component: Dijit Version: 1.7.2
Keywords: Cc: Akira Sudoh
Blocked By: Blocking:

Description (last modified by bill)

There are lots of places in dijit that reference dojo/_base/window::doc (aka win.doc or dojo.doc) either directly, or indirectly, for example win.body(). But each widget essentially has a document that is set at construction time, usually implied by srcNodeRef.ownerDocument. So, widgets' references to win.doc typically create an unnecessary dependency on dojo/_base/window, and also preclude creating those widgets in another frame.

Most of the code in core doesn't have this problem. dom.byId(), for example, takes an optional document argument, and can infer the document via the refNode However, there are a few places in core that should be cleaned as it makes unnecessary assumptions about which document to use.

So, this ticket covers adding a this.doc member to _WidgetBase to point to the widget's document, removing unnecessary references to win.doc for dijit widgets, and cleaning up a few spots in core.

See spreadsheet from Akira for list of places to update.

Change History (3)

comment:1 Changed 10 years ago by bill

Cc: Akira Sudoh added
Milestone: tbd1.8
Owner: set to bill
Status: newassigned
Type: defecttask

comment:2 Changed 10 years ago by bill

In [28401]:

Removing dependency on win.doc global-ish variable:

  • Each widget has a document determined at creation time, usually implied by srcNodeRef.ownerDocument but also specifiable explicitly. Save that in this.ownerDocument, and for convenience also record the associated <body> node in this.ownerDocumentBody. Maybe this.ownerDocument should be called this.doc instead, but I thought that might be confusing with Editor.document.
  • In widgets, use this.ownerDocument instead of win.doc, and this.ownerDocumentBody instead of win.body().
  • Since domConstruct.create() doesn't take a document parameter, either pass in a refNode (which implies the document), or avoid using domConstruct.create(). Could also have wrapped the domConstruct.create() calls with win.withDoc(), or used domConstruct.toDom().
  • Miscellaneous fixes to widgets.
  • Make dojo/_base/window::body() take an optional document parameter.

Editor not yet converted.

Refs #15216 !strict.

comment:3 Changed 10 years ago by bill

Description: modified (diff)


  • #15525 for issues with lite engine.
  • #15226 for adding doc param to domConstruct.create()
  • #15229 for other changes to dojo core DOM methods
Last edited 10 years ago by bill (previous) (diff)
Note: See TracTickets for help on using tickets.