Opened 8 years ago

Last modified 4 years ago

#15226 assigned enhancement

dom.create() document parameter — at Initial Version

Reported by: bill Owned by: Eugene Lazutkin
Priority: undecided Milestone: 1.15
Component: HTML Version: 1.7.2
Keywords: Cc:
Blocked By: Blocking:

Description

Most of the methods in the dom* modules allow explicitly or implicitly specifying a document. For example:

  • dom.byId(id, doc) looks up "id" in document "doc"
  • domConstruct.place("<div>hi</div>", refNode) creates the <div> in refNode.ownerDocument

However, domConstruct.create() doesn't take a document, so you can't easily specify a document for a case like:

domConstruct.create("div", {role: "dialog", innerHTML: "hi"});

If your code has a refNode, the document is implied by the refNode:

domConstruct.create("div", {role: "dialog", innerHTML: "hi"}, refNode);

However, sometimes there's no refNode, in which case you either need to stop using domConstruct.create(), ex:

var div = myDoc.createElement("div");
domAttr.set(div, {role: "dialog", innerHTML: "hi"});

or

var div = domConstruct.toDom("<div role=dialog>hi</div>")[0];

or use the dojo/_base/window withDoc() mechanism, which is a little clunky:

win.withDoc(myDoc, function(){
   domConstruct.create("div", {role: "dialog", innerHTML: "hi"});
});

(I'm also not sure if withDoc() will be around in 2.0.)

So, this is a ticket to consider adding a document parameter to the create() method.

Change History (0)

Note: See TracTickets for help on using tickets.