Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#15225 closed defect (fixed)

lite engine doesn't respect win.doc or root.ownerDocument setting

Reported by: bill Owned by: Kris Zyp
Priority: undecided Milestone: 1.8
Component: Query Version: 1.7.2
Keywords: Cc:
Blocked By: Blocking:

Description

lite.js has a number of references to the "document" global, leading to the problems:

  • A query without a root node, ex: query("#foo") or query("div"), will run against document, rather than win.doc (dojo/_base/window::doc). Usually they are the same, but it's possible they are different due to a win.withDoc() call etc.
  • A query with a root node, ex: query("div", root), should run against root.ownerDocument, rather than document or win.doc.

Lite.js should be computing the doc to use as root.ownerDocument || win.doc.

Also, the dojo.byId(match[2]) call is problematic since it isn't using root.ownerDocument (if root was defined). It needs a second argument of the document: byId(match[2], doc).

The dojo.byId() call is also problematic since it depends on the "dojo" global, which isn't set in builds where has("extend-dojo") == false, and will never be set starting with 2.0. Probably the lite module should just import dojo/dom; it could do a try{ byId = require("dojo/dom").byId; }catch(){} but generally exceptions should be reserved for exceptional cases.

Change History (2)

comment:1 Changed 7 years ago by Kris Zyp

Resolution: fixed
Status: newclosed

In [29137]:

Use dojo.doc to determine document for querying, fixes #15225 !strict

comment:2 Changed 7 years ago by Kris Zyp

Milestone: tbd1.8
Note: See TracTickets for help on using tickets.