dojo/html.js

  • Provides:

    • dojo.html
  • dojo.html._ContentSetter

    • type
      Function
    • parameters:
      • params: (typeof Object)
      • node: (typeof String|DomNode)
    • source: [view]
          dojo.mixin(this, params || {});


          // give precedence to params.node vs. the node argument
          // and ensure its a node, not an id string
          node = this.node = dojo.byId( this.node || node );

       
          if(!this.id){
           this.id = [
            "Setter",
            (node) ? node.id || node.tagName : "",
            idCounter++
           ].join("_");
          }
    • summary
      Provides a configurable, extensible object to wrap the setting on content on a node
      call the set() method to actually set the content..
      
      the original params are mixed directly into the instance "this"
  • dojo.html._ContentSetter.node

    • type
      DomNode|String
    • summary
      An node which will be the parent element that we set content into
  • dojo.html._ContentSetter.content

    • type
      String|DomNode|DomNode[
    • summary
      The content to be placed in the node. Can be an HTML string, a node reference, or a enumerable list of nodes
  • dojo.html._ContentSetter.id

    • type
      String
    • summary
      Usually only used internally, and auto-generated with each instance
  • dojo.html._ContentSetter.cleanContent

    • type
      Boolean
    • summary
      Should the content be treated as a full html document,
      and the real content stripped of <html>, <body> wrapper before injection
  • dojo.html._ContentSetter.extractContent

    • type
      Boolean
    • summary
      Should the content be treated as a full html document, and the real content stripped of <html>, <body> wrapper before injection
  • dojo.html._ContentSetter.parseContent

    • type
      Boolean
    • summary
      Should the node by passed to the parser after the new content is set
  • dojo.html._ContentSetter.parserScope

    • type
      String
    • summary
      Flag passed to parser.  Root for attribute names to search for.   If scopeName is dojo,
      will search for data-dojo-type (or dojoType).  For backwards compatibility
      reasons defaults to dojo._scopeName (which is "dojo" except when
      multi-version support is used, when it will be something like dojo16, dojo20, etc.)
  • dojo.html._ContentSetter.startup

    • type
      Boolean
    • summary
      Start the child widgets after parsing them.   Only obeyed if parseContent is true.
      
      
      lifecyle methods
  • dojo.html._ContentSetter.set

    • type
      Function
    • parameters:
      • cont: (typeof String|DomNode|NodeList)
        An html string, node or enumerable list of nodes for insertion into the dom
        If not provided, the object's content property will be used
      • params: (typeof Object)
    • source: [view]
          if(undefined !== cont){
           this.content = cont;
          }
          // in the re-use scenario, set needs to be able to mixin new configuration
          if(params){
           this._mixin(params);
          }


          this.onBegin();
          this.setContent();
          this.onEnd();


          return this.node;
    • summary
      front-end to the set-content sequence
  • dojo.html._ContentSetter.setContent

    • type
      Function
    • source: [view]
          var node = this.node;
          if(!node) {
           // can't proceed
           throw new Error(this.declaredClass + ": setContent given no node");
          }
          try{
           node = dojo.html._setNodeContent(node, this.content);
          }catch(e){
           // check if a domfault occurs when we are appending this.errorMessage
           // like for instance if domNode is a UL and we try append a DIV

       
           // FIXME: need to allow the user to provide a content error message string
           var errMess = this.onContentError(e);
           try{
            node.innerHTML = errMess;
           }catch(e){
            console.error('Fatal ' + this.declaredClass + '.setContent could not change content due to '+e.message, e);
           }
          }
          // always put back the node for the next method
          this.node = node; // DomNode
    • summary
      sets the content on the node
  • dojo.html._ContentSetter.empty

    • type
      Function
    • source: [view]
      define("dojo/html", ["dojo", "dojo/parser"], function(dojo) {
      dojo.getObject("html", true, dojo);


      // the parser might be needed..
      (function(){ // private scope, sort of a namespace


       // idCounter is incremented with each instantiation to allow asignment of a unique id for tracking, logging purposes
       var idCounter = 0,
        d = dojo;

       
       dojo.html._secureForInnerHtml = function(/*String*/ cont){
        // summary:
        //  removes !DOCTYPE and title elements from the html string.
        //
        //  khtml is picky about dom faults, you can't attach a style or node as child of body<br>  //  must go into head, so we need to cut out those tags<br>  // cont:<br>  //  An html string for insertion into the dom<br>  //<br>  return cont.replace(/(?:\s*<!DOCTYPE\s[^>]+>|<title[^>]*>[\s\S]*?<\/title>)/ig, ""); // String<br> };<br><br><br>/*====<br> dojo.html._emptyNode = function(node){<br>  // summary:<br>  //  removes all child nodes from the given node<br>  // node: DOMNode<br>  //  the parent element<br> };<br>=====*/<br> dojo.html._emptyNode = dojo.empty;<br><br><br> dojo.html._setNodeContent = function(/* DomNode */ node, /* String|DomNode|NodeList */ cont){<br>  // summary:<br>  //  inserts the given content into the given node<br>  // node:<br>  //  the parent element<br>  // content:<br>  //  the content to be set on the parent element.<br>  //  This can be an html string, a node reference or a NodeList, dojo.NodeList, Array or other enumerable list of nodes<br><br>  <br>  // always empty<br>  d.empty(node);<br><br><br>  if(cont) {<br>   if(typeof cont == "string") {<br>    cont = d._toDom(cont, node.ownerDocument);<br>   }<br>   if(!cont.nodeType && d.isArrayLike(cont)) {<br>    // handle as enumerable, but it may shrink as we enumerate it<br>    for(var startlen=cont.length, i=0; i<cont.length; i=startlen==cont.length ? i+1 : 0) {<br>     d.place( cont[i], node, "last");<br>    }<br>   } else {<br>    // pass nodes, documentFragments and unknowns through to dojo.place<br>    d.place(cont, node, "last");<br>   }<br>  }<br><br><br>  // return DomNode<br>  return node;<br> };<br><br><br> // we wrap up the content-setting operation in a object<br> dojo.declare("dojo.html._ContentSetter", null,<br>  {<br>   // node: DomNode|String<br>   //  An node which will be the parent element that we set content into<br>   node: "",<br><br><br>   // content: String|DomNode|DomNode[]<br>   //  The content to be placed in the node. Can be an HTML string, a node reference, or a enumerable list of nodes<br>   content: "",<br><br>   <br>   // id: String?<br>   //  Usually only used internally, and auto-generated with each instance<br>   id: "",<br><br><br>   // cleanContent: Boolean<br>   //  Should the content be treated as a full html document,<br>   //  and the real content stripped of <html>, <body> wrapper before injection<br>   cleanContent: false,<br><br>   <br>   // extractContent: Boolean<br>   //  Should the content be treated as a full html document, and the real content stripped of <html>, <body> wrapper before injection<br>   extractContent: false,<br><br><br>   // parseContent: Boolean<br>   //  Should the node by passed to the parser after the new content is set<br>   parseContent: false,<br><br><br>   // parserScope: String<br>   //  Flag passed to parser. Root for attribute names to search for. If scopeName is dojo,<br>   //  will search for data-dojo-type (or dojoType). For backwards compatibility<br>   //  reasons defaults to dojo._scopeName (which is "dojo" except when<br>   //  multi-version support is used, when it will be something like dojo16, dojo20, etc.)<br>   parserScope: dojo._scopeName,<br><br><br>   // startup: Boolean<br>   //  Start the child widgets after parsing them. Only obeyed if parseContent is true.<br>   startup: true,<br><br>   <br>   // lifecyle methods<br>   constructor: function(/* Object */params, /* String|DomNode */node){<br>    // summary:<br>    //  Provides a configurable, extensible object to wrap the setting on content on a node<br>    //  call the set() method to actually set the content..<br><br> <br>    // the original params are mixed directly into the instance "this"<br>    dojo.mixin(this, params || {});<br><br><br>    // give precedence to params.node vs. the node argument<br>    // and ensure its a node, not an id string<br>    node = this.node = dojo.byId( this.node || node );<br><br> <br>    if(!this.id){<br>     this.id = [<br>      "Setter",<br>      (node) ? node.id || node.tagName : "",<br>      idCounter++<br>     ].join("_");<br>    }<br>   },<br>   set: function(/* String|DomNode|NodeList? */ cont, /* Object? */ params){<br>    // summary:<br>    //  front-end to the set-content sequence<br>    // cont:<br>    //  An html string, node or enumerable list of nodes for insertion into the dom<br>    //  If not provided, the object's content property will be used<br>    if(undefined !== cont){<br>     this.content = cont;<br>    }<br>    // in the re-use scenario, set needs to be able to mixin new configuration<br>    if(params){<br>     this._mixin(params);<br>    }<br><br><br>    this.onBegin();<br>    this.setContent();<br>    this.onEnd();<br><br><br>    return this.node;<br>   },<br>   setContent: function(){<br>    // summary:<br>    //  sets the content on the node<br><br><br>    var node = this.node;<br>    if(!node) {<br>     // can't proceed<br>     throw new Error(this.declaredClass + ": setContent given no node");<br>    }<br>    try{<br>     node = dojo.html._setNodeContent(node, this.content);<br>    }catch(e){<br>     // check if a domfault occurs when we are appending this.errorMessage<br>     // like for instance if domNode is a UL and we try append a DIV<br><br> <br>     // FIXME: need to allow the user to provide a content error message string<br>     var errMess = this.onContentError(e);<br>     try{<br>      node.innerHTML = errMess;<br>     }catch(e){<br>      console.error('Fatal ' + this.declaredClass + '.setContent could not change content due to '+e.message, e);<br>     }<br>    }<br>    // always put back the node for the next method<br>    this.node = node; // DomNode<br>   },<br><br>   <br>   empty: function() {<br>    // summary<br>    // cleanly empty out existing content<br><br><br>    // destroy any widgets from a previous run<br>    // NOTE: if you dont want this you'll need to empty<br>    // the parseResults array property yourself to avoid bad things happenning<br>    if(this.parseResults && this.parseResults.length) {<br>     dojo.forEach(this.parseResults, function(w) {<br>      if(w.destroy){<br>       w.destroy();<br>      }<br>     });<br>     delete this.parseResults;<br>    }<br>    // this is fast, but if you know its already empty or safe, you could<br>    // override empty to skip this step<br>    dojo.html._emptyNode(this.node); </div> <li><em>returns</em><div><pre>String</pre></div></li><li><em>summary</em><div><pre></pre></div></li></ul></li><li><h4>dojo.html._ContentSetter.onBegin</h4><ul> <li><em>type</em><div><pre>Function</pre></div></li><li class="source"><em>source: [<a onclick="tgShow('unique5');">view</a>]</em> <div class="nosho" id="unique5"> define("dojo/html", ["dojo", "dojo/parser"], function(dojo) {<br>dojo.getObject("html", true, dojo);<br><br><br>// the parser might be needed..<br>(function(){ // private scope, sort of a namespace<br><br><br> // idCounter is incremented with each instantiation to allow asignment of a unique id for tracking, logging purposes<br> var idCounter = 0,<br>  d = dojo;<br><br> <br> dojo.html._secureForInnerHtml = function(/*String*/ cont){<br>  // summary:<br>  //  removes !DOCTYPE and title elements from the html string.<br>  //<br>  //  khtml is picky about dom faults, you can't attach a style or <title> node as child of body<br>  //  must go into head, so we need to cut out those tags<br>  // cont:<br>  //  An html string for insertion into the dom<br>  //<br>  return cont.replace(/(?:\s*<!DOCTYPE\s[^>]+>|<title[^>]*>[\s\S]*?<\/title>)/ig, ""); // String<br> };<br><br><br>/*====<br> dojo.html._emptyNode = function(node){<br>  // summary:<br>  //  removes all child nodes from the given node<br>  // node: DOMNode<br>  //  the parent element<br> };<br>=====*/<br> dojo.html._emptyNode = dojo.empty;<br><br><br> dojo.html._setNodeContent = function(/* DomNode */ node, /* String|DomNode|NodeList */ cont){<br>  // summary:<br>  //  inserts the given content into the given node<br>  // node:<br>  //  the parent element<br>  // content:<br>  //  the content to be set on the parent element.<br>  //  This can be an html string, a node reference or a NodeList, dojo.NodeList, Array or other enumerable list of nodes<br><br>  <br>  // always empty<br>  d.empty(node);<br><br><br>  if(cont) {<br>   if(typeof cont == "string") {<br>    cont = d._toDom(cont, node.ownerDocument);<br>   }<br>   if(!cont.nodeType && d.isArrayLike(cont)) {<br>    // handle as enumerable, but it may shrink as we enumerate it<br>    for(var startlen=cont.length, i=0; i<cont.length; i=startlen==cont.length ? i+1 : 0) {<br>     d.place( cont[i], node, "last");<br>    }<br>   } else {<br>    // pass nodes, documentFragments and unknowns through to dojo.place<br>    d.place(cont, node, "last");<br>   }<br>  }<br><br><br>  // return DomNode<br>  return node;<br> };<br><br><br> // we wrap up the content-setting operation in a object<br> dojo.declare("dojo.html._ContentSetter", null,<br>  {<br>   // node: DomNode|String<br>   //  An node which will be the parent element that we set content into<br>   node: "",<br><br><br>   // content: String|DomNode|DomNode[]<br>   //  The content to be placed in the node. Can be an HTML string, a node reference, or a enumerable list of nodes<br>   content: "",<br><br>   <br>   // id: String?<br>   //  Usually only used internally, and auto-generated with each instance<br>   id: "",<br><br><br>   // cleanContent: Boolean<br>   //  Should the content be treated as a full html document,<br>   //  and the real content stripped of <html>, <body> wrapper before injection<br>   cleanContent: false,<br><br>   <br>   // extractContent: Boolean<br>   //  Should the content be treated as a full html document, and the real content stripped of <html>, <body> wrapper before injection<br>   extractContent: false,<br><br><br>   // parseContent: Boolean<br>   //  Should the node by passed to the parser after the new content is set<br>   parseContent: false,<br><br><br>   // parserScope: String<br>   //  Flag passed to parser. Root for attribute names to search for. If scopeName is dojo,<br>   //  will search for data-dojo-type (or dojoType). For backwards compatibility<br>   //  reasons defaults to dojo._scopeName (which is "dojo" except when<br>   //  multi-version support is used, when it will be something like dojo16, dojo20, etc.)<br>   parserScope: dojo._scopeName,<br><br><br>   // startup: Boolean<br>   //  Start the child widgets after parsing them. Only obeyed if parseContent is true.<br>   startup: true,<br><br>   <br>   // lifecyle methods<br>   constructor: function(/* Object */params, /* String|DomNode */node){<br>    // summary:<br>    //  Provides a configurable, extensible object to wrap the setting on content on a node<br>    //  call the set() method to actually set the content..<br><br> <br>    // the original params are mixed directly into the instance "this"<br>    dojo.mixin(this, params || {});<br><br><br>    // give precedence to params.node vs. the node argument<br>    // and ensure its a node, not an id string<br>    node = this.node = dojo.byId( this.node || node );<br><br> <br>    if(!this.id){<br>     this.id = [<br>      "Setter",<br>      (node) ? node.id || node.tagName : "",<br>      idCounter++<br>     ].join("_");<br>    }<br>   },<br>   set: function(/* String|DomNode|NodeList? */ cont, /* Object? */ params){<br>    // summary:<br>    //  front-end to the set-content sequence<br>    // cont:<br>    //  An html string, node or enumerable list of nodes for insertion into the dom<br>    //  If not provided, the object's content property will be used<br>    if(undefined !== cont){<br>     this.content = cont;<br>    }<br>    // in the re-use scenario, set needs to be able to mixin new configuration<br>    if(params){<br>     this._mixin(params);<br>    }<br><br><br>    this.onBegin();<br>    this.setContent();<br>    this.onEnd();<br><br><br>    return this.node;<br>   },<br>   setContent: function(){<br>    // summary:<br>    //  sets the content on the node<br><br><br>    var node = this.node;<br>    if(!node) {<br>     // can't proceed<br>     throw new Error(this.declaredClass + ": setContent given no node");<br>    }<br>    try{<br>     node = dojo.html._setNodeContent(node, this.content);<br>    }catch(e){<br>     // check if a domfault occurs when we are appending this.errorMessage<br>     // like for instance if domNode is a UL and we try append a DIV<br><br> <br>     // FIXME: need to allow the user to provide a content error message string<br>     var errMess = this.onContentError(e);<br>     try{<br>      node.innerHTML = errMess;<br>     }catch(e){<br>      console.error('Fatal ' + this.declaredClass + '.setContent could not change content due to '+e.message, e);<br>     }<br>    }<br>    // always put back the node for the next method<br>    this.node = node; // DomNode<br>   },<br><br>   <br>   empty: function() {<br>    // summary<br>    // cleanly empty out existing content<br><br><br>    // destroy any widgets from a previous run<br>    // NOTE: if you dont want this you'll need to empty<br>    // the parseResults array property yourself to avoid bad things happenning<br>    if(this.parseResults && this.parseResults.length) {<br>     dojo.forEach(this.parseResults, function(w) {<br>      if(w.destroy){<br>       w.destroy();<br>      }<br>     });<br>     delete this.parseResults;<br>    }<br>    // this is fast, but if you know its already empty or safe, you could<br>    // override empty to skip this step<br>    dojo.html._emptyNode(this.node);<br>   },<br><br> <br>   onBegin: function(){<br>    // summary<br>    //  Called after instantiation, but before set();<br>    //  It allows modification of any of the object properties<br>    //  - including the node and content provided - before the set operation actually takes place<br>    //  This default implementation checks for cleanContent and extractContent flags to<br>    //  optionally pre-process html string content<br>    var cont = this.content;<br><br> <br>    if(dojo.isString(cont)){<br>     if(this.cleanContent){<br>      cont = dojo.html._secureForInnerHtml(cont);<br>     }<br><br> <br>     if(this.extractContent){<br>      var match = cont.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im);<br>      if(match){ cont = match[1]; }<br>     }<br>    }<br><br><br>    // clean out the node and any cruft associated with it - like widgets<br>    this.empty();<br><br>    <br>    this.content = cont;<br>    return this.node; /* DomNode */ </div> <li><em>returns</em><div><pre>String|DomNode</pre></div></li><li><em>summary</em><div><pre></pre></div></li></ul></li><li><h4>dojo.html._ContentSetter.onEnd</h4><ul> <li><em>type</em><div><pre>Function</pre></div></li><li class="source"><em>source: [<a onclick="tgShow('unique6');">view</a>]</em> <div class="nosho" id="unique6"> define("dojo/html", ["dojo", "dojo/parser"], function(dojo) {<br>dojo.getObject("html", true, dojo);<br><br><br>// the parser might be needed..<br>(function(){ // private scope, sort of a namespace<br><br><br> // idCounter is incremented with each instantiation to allow asignment of a unique id for tracking, logging purposes<br> var idCounter = 0,<br>  d = dojo;<br><br> <br> dojo.html._secureForInnerHtml = function(/*String*/ cont){<br>  // summary:<br>  //  removes !DOCTYPE and title elements from the html string.<br>  //<br>  //  khtml is picky about dom faults, you can't attach a style or <title> node as child of body<br>  //  must go into head, so we need to cut out those tags<br>  // cont:<br>  //  An html string for insertion into the dom<br>  //<br>  return cont.replace(/(?:\s*<!DOCTYPE\s[^>]+>|<title[^>]*>[\s\S]*?<\/title>)/ig, ""); // String<br> };<br><br><br>/*====<br> dojo.html._emptyNode = function(node){<br>  // summary:<br>  //  removes all child nodes from the given node<br>  // node: DOMNode<br>  //  the parent element<br> };<br>=====*/<br> dojo.html._emptyNode = dojo.empty;<br><br><br> dojo.html._setNodeContent = function(/* DomNode */ node, /* String|DomNode|NodeList */ cont){<br>  // summary:<br>  //  inserts the given content into the given node<br>  // node:<br>  //  the parent element<br>  // content:<br>  //  the content to be set on the parent element.<br>  //  This can be an html string, a node reference or a NodeList, dojo.NodeList, Array or other enumerable list of nodes<br><br>  <br>  // always empty<br>  d.empty(node);<br><br><br>  if(cont) {<br>   if(typeof cont == "string") {<br>    cont = d._toDom(cont, node.ownerDocument);<br>   }<br>   if(!cont.nodeType && d.isArrayLike(cont)) {<br>    // handle as enumerable, but it may shrink as we enumerate it<br>    for(var startlen=cont.length, i=0; i<cont.length; i=startlen==cont.length ? i+1 : 0) {<br>     d.place( cont[i], node, "last");<br>    }<br>   } else {<br>    // pass nodes, documentFragments and unknowns through to dojo.place<br>    d.place(cont, node, "last");<br>   }<br>  }<br><br><br>  // return DomNode<br>  return node;<br> };<br><br><br> // we wrap up the content-setting operation in a object<br> dojo.declare("dojo.html._ContentSetter", null,<br>  {<br>   // node: DomNode|String<br>   //  An node which will be the parent element that we set content into<br>   node: "",<br><br><br>   // content: String|DomNode|DomNode[]<br>   //  The content to be placed in the node. Can be an HTML string, a node reference, or a enumerable list of nodes<br>   content: "",<br><br>   <br>   // id: String?<br>   //  Usually only used internally, and auto-generated with each instance<br>   id: "",<br><br><br>   // cleanContent: Boolean<br>   //  Should the content be treated as a full html document,<br>   //  and the real content stripped of <html>, <body> wrapper before injection<br>   cleanContent: false,<br><br>   <br>   // extractContent: Boolean<br>   //  Should the content be treated as a full html document, and the real content stripped of <html>, <body> wrapper before injection<br>   extractContent: false,<br><br><br>   // parseContent: Boolean<br>   //  Should the node by passed to the parser after the new content is set<br>   parseContent: false,<br><br><br>   // parserScope: String<br>   //  Flag passed to parser. Root for attribute names to search for. If scopeName is dojo,<br>   //  will search for data-dojo-type (or dojoType). For backwards compatibility<br>   //  reasons defaults to dojo._scopeName (which is "dojo" except when<br>   //  multi-version support is used, when it will be something like dojo16, dojo20, etc.)<br>   parserScope: dojo._scopeName,<br><br><br>   // startup: Boolean<br>   //  Start the child widgets after parsing them. Only obeyed if parseContent is true.<br>   startup: true,<br><br>   <br>   // lifecyle methods<br>   constructor: function(/* Object */params, /* String|DomNode */node){<br>    // summary:<br>    //  Provides a configurable, extensible object to wrap the setting on content on a node<br>    //  call the set() method to actually set the content..<br><br> <br>    // the original params are mixed directly into the instance "this"<br>    dojo.mixin(this, params || {});<br><br><br>    // give precedence to params.node vs. the node argument<br>    // and ensure its a node, not an id string<br>    node = this.node = dojo.byId( this.node || node );<br><br> <br>    if(!this.id){<br>     this.id = [<br>      "Setter",<br>      (node) ? node.id || node.tagName : "",<br>      idCounter++<br>     ].join("_");<br>    }<br>   },<br>   set: function(/* String|DomNode|NodeList? */ cont, /* Object? */ params){<br>    // summary:<br>    //  front-end to the set-content sequence<br>    // cont:<br>    //  An html string, node or enumerable list of nodes for insertion into the dom<br>    //  If not provided, the object's content property will be used<br>    if(undefined !== cont){<br>     this.content = cont;<br>    }<br>    // in the re-use scenario, set needs to be able to mixin new configuration<br>    if(params){<br>     this._mixin(params);<br>    }<br><br><br>    this.onBegin();<br>    this.setContent();<br>    this.onEnd();<br><br><br>    return this.node;<br>   },<br>   setContent: function(){<br>    // summary:<br>    //  sets the content on the node<br><br><br>    var node = this.node;<br>    if(!node) {<br>     // can't proceed<br>     throw new Error(this.declaredClass + ": setContent given no node");<br>    }<br>    try{<br>     node = dojo.html._setNodeContent(node, this.content);<br>    }catch(e){<br>     // check if a domfault occurs when we are appending this.errorMessage<br>     // like for instance if domNode is a UL and we try append a DIV<br><br> <br>     // FIXME: need to allow the user to provide a content error message string<br>     var errMess = this.onContentError(e);<br>     try{<br>      node.innerHTML = errMess;<br>     }catch(e){<br>      console.error('Fatal ' + this.declaredClass + '.setContent could not change content due to '+e.message, e);<br>     }<br>    }<br>    // always put back the node for the next method<br>    this.node = node; // DomNode<br>   },<br><br>   <br>   empty: function() {<br>    // summary<br>    // cleanly empty out existing content<br><br><br>    // destroy any widgets from a previous run<br>    // NOTE: if you dont want this you'll need to empty<br>    // the parseResults array property yourself to avoid bad things happenning<br>    if(this.parseResults && this.parseResults.length) {<br>     dojo.forEach(this.parseResults, function(w) {<br>      if(w.destroy){<br>       w.destroy();<br>      }<br>     });<br>     delete this.parseResults;<br>    }<br>    // this is fast, but if you know its already empty or safe, you could<br>    // override empty to skip this step<br>    dojo.html._emptyNode(this.node);<br>   },<br><br> <br>   onBegin: function(){<br>    // summary<br>    //  Called after instantiation, but before set();<br>    //  It allows modification of any of the object properties<br>    //  - including the node and content provided - before the set operation actually takes place<br>    //  This default implementation checks for cleanContent and extractContent flags to<br>    //  optionally pre-process html string content<br>    var cont = this.content;<br><br> <br>    if(dojo.isString(cont)){<br>     if(this.cleanContent){<br>      cont = dojo.html._secureForInnerHtml(cont);<br>     }<br><br> <br>     if(this.extractContent){<br>      var match = cont.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im);<br>      if(match){ cont = match[1]; }<br>     }<br>    }<br><br><br>    // clean out the node and any cruft associated with it - like widgets<br>    this.empty();<br><br>    <br>    this.content = cont;<br>    return this.node; /* DomNode */<br>   },<br><br> <br>   onEnd: function(){<br>    // summary<br>    //  Called after set(), when the new content has been pushed into the node<br>    //  It provides an opportunity for post-processing before handing back the node to the caller<br>    //  This default implementation checks a parseContent flag to optionally run the dojo parser over the new content<br>    if(this.parseContent){<br>     // populates this.parseResults if you need those..<br>     this._parse();<br>    }<br>    return this.node; /* DomNode */ </div> <li><em>returns</em><div><pre>String|DomNode</pre></div></li><li><em>summary</em><div><pre></pre></div></li></ul></li><li><h4>dojo.html._ContentSetter.tearDown</h4><ul> <li><em>type</em><div><pre>Function</pre></div></li><li class="source"><em>source: [<a onclick="tgShow('unique7');">view</a>]</em> <div class="nosho" id="unique7"> define("dojo/html", ["dojo", "dojo/parser"], function(dojo) {<br>dojo.getObject("html", true, dojo);<br><br><br>// the parser might be needed..<br>(function(){ // private scope, sort of a namespace<br><br><br> // idCounter is incremented with each instantiation to allow asignment of a unique id for tracking, logging purposes<br> var idCounter = 0,<br>  d = dojo;<br><br> <br> dojo.html._secureForInnerHtml = function(/*String*/ cont){<br>  // summary:<br>  //  removes !DOCTYPE and title elements from the html string.<br>  //<br>  //  khtml is picky about dom faults, you can't attach a style or <title> node as child of body<br>  //  must go into head, so we need to cut out those tags<br>  // cont:<br>  //  An html string for insertion into the dom<br>  //<br>  return cont.replace(/(?:\s*<!DOCTYPE\s[^>]+>|<title[^>]*>[\s\S]*?<\/title>)/ig, ""); // String<br> };<br><br><br>/*====<br> dojo.html._emptyNode = function(node){<br>  // summary:<br>  //  removes all child nodes from the given node<br>  // node: DOMNode<br>  //  the parent element<br> };<br>=====*/<br> dojo.html._emptyNode = dojo.empty;<br><br><br> dojo.html._setNodeContent = function(/* DomNode */ node, /* String|DomNode|NodeList */ cont){<br>  // summary:<br>  //  inserts the given content into the given node<br>  // node:<br>  //  the parent element<br>  // content:<br>  //  the content to be set on the parent element.<br>  //  This can be an html string, a node reference or a NodeList, dojo.NodeList, Array or other enumerable list of nodes<br><br>  <br>  // always empty<br>  d.empty(node);<br><br><br>  if(cont) {<br>   if(typeof cont == "string") {<br>    cont = d._toDom(cont, node.ownerDocument);<br>   }<br>   if(!cont.nodeType && d.isArrayLike(cont)) {<br>    // handle as enumerable, but it may shrink as we enumerate it<br>    for(var startlen=cont.length, i=0; i<cont.length; i=startlen==cont.length ? i+1 : 0) {<br>     d.place( cont[i], node, "last");<br>    }<br>   } else {<br>    // pass nodes, documentFragments and unknowns through to dojo.place<br>    d.place(cont, node, "last");<br>   }<br>  }<br><br><br>  // return DomNode<br>  return node;<br> };<br><br><br> // we wrap up the content-setting operation in a object<br> dojo.declare("dojo.html._ContentSetter", null,<br>  {<br>   // node: DomNode|String<br>   //  An node which will be the parent element that we set content into<br>   node: "",<br><br><br>   // content: String|DomNode|DomNode[]<br>   //  The content to be placed in the node. Can be an HTML string, a node reference, or a enumerable list of nodes<br>   content: "",<br><br>   <br>   // id: String?<br>   //  Usually only used internally, and auto-generated with each instance<br>   id: "",<br><br><br>   // cleanContent: Boolean<br>   //  Should the content be treated as a full html document,<br>   //  and the real content stripped of <html>, <body> wrapper before injection<br>   cleanContent: false,<br><br>   <br>   // extractContent: Boolean<br>   //  Should the content be treated as a full html document, and the real content stripped of <html>, <body> wrapper before injection<br>   extractContent: false,<br><br><br>   // parseContent: Boolean<br>   //  Should the node by passed to the parser after the new content is set<br>   parseContent: false,<br><br><br>   // parserScope: String<br>   //  Flag passed to parser. Root for attribute names to search for. If scopeName is dojo,<br>   //  will search for data-dojo-type (or dojoType). For backwards compatibility<br>   //  reasons defaults to dojo._scopeName (which is "dojo" except when<br>   //  multi-version support is used, when it will be something like dojo16, dojo20, etc.)<br>   parserScope: dojo._scopeName,<br><br><br>   // startup: Boolean<br>   //  Start the child widgets after parsing them. Only obeyed if parseContent is true.<br>   startup: true,<br><br>   <br>   // lifecyle methods<br>   constructor: function(/* Object */params, /* String|DomNode */node){<br>    // summary:<br>    //  Provides a configurable, extensible object to wrap the setting on content on a node<br>    //  call the set() method to actually set the content..<br><br> <br>    // the original params are mixed directly into the instance "this"<br>    dojo.mixin(this, params || {});<br><br><br>    // give precedence to params.node vs. the node argument<br>    // and ensure its a node, not an id string<br>    node = this.node = dojo.byId( this.node || node );<br><br> <br>    if(!this.id){<br>     this.id = [<br>      "Setter",<br>      (node) ? node.id || node.tagName : "",<br>      idCounter++<br>     ].join("_");<br>    }<br>   },<br>   set: function(/* String|DomNode|NodeList? */ cont, /* Object? */ params){<br>    // summary:<br>    //  front-end to the set-content sequence<br>    // cont:<br>    //  An html string, node or enumerable list of nodes for insertion into the dom<br>    //  If not provided, the object's content property will be used<br>    if(undefined !== cont){<br>     this.content = cont;<br>    }<br>    // in the re-use scenario, set needs to be able to mixin new configuration<br>    if(params){<br>     this._mixin(params);<br>    }<br><br><br>    this.onBegin();<br>    this.setContent();<br>    this.onEnd();<br><br><br>    return this.node;<br>   },<br>   setContent: function(){<br>    // summary:<br>    //  sets the content on the node<br><br><br>    var node = this.node;<br>    if(!node) {<br>     // can't proceed<br>     throw new Error(this.declaredClass + ": setContent given no node");<br>    }<br>    try{<br>     node = dojo.html._setNodeContent(node, this.content);<br>    }catch(e){<br>     // check if a domfault occurs when we are appending this.errorMessage<br>     // like for instance if domNode is a UL and we try append a DIV<br><br> <br>     // FIXME: need to allow the user to provide a content error message string<br>     var errMess = this.onContentError(e);<br>     try{<br>      node.innerHTML = errMess;<br>     }catch(e){<br>      console.error('Fatal ' + this.declaredClass + '.setContent could not change content due to '+e.message, e);<br>     }<br>    }<br>    // always put back the node for the next method<br>    this.node = node; // DomNode<br>   },<br><br>   <br>   empty: function() {<br>    // summary<br>    // cleanly empty out existing content<br><br><br>    // destroy any widgets from a previous run<br>    // NOTE: if you dont want this you'll need to empty<br>    // the parseResults array property yourself to avoid bad things happenning<br>    if(this.parseResults && this.parseResults.length) {<br>     dojo.forEach(this.parseResults, function(w) {<br>      if(w.destroy){<br>       w.destroy();<br>      }<br>     });<br>     delete this.parseResults;<br>    }<br>    // this is fast, but if you know its already empty or safe, you could<br>    // override empty to skip this step<br>    dojo.html._emptyNode(this.node);<br>   },<br><br> <br>   onBegin: function(){<br>    // summary<br>    //  Called after instantiation, but before set();<br>    //  It allows modification of any of the object properties<br>    //  - including the node and content provided - before the set operation actually takes place<br>    //  This default implementation checks for cleanContent and extractContent flags to<br>    //  optionally pre-process html string content<br>    var cont = this.content;<br><br> <br>    if(dojo.isString(cont)){<br>     if(this.cleanContent){<br>      cont = dojo.html._secureForInnerHtml(cont);<br>     }<br><br> <br>     if(this.extractContent){<br>      var match = cont.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im);<br>      if(match){ cont = match[1]; }<br>     }<br>    }<br><br><br>    // clean out the node and any cruft associated with it - like widgets<br>    this.empty();<br><br>    <br>    this.content = cont;<br>    return this.node; /* DomNode */<br>   },<br><br> <br>   onEnd: function(){<br>    // summary<br>    //  Called after set(), when the new content has been pushed into the node<br>    //  It provides an opportunity for post-processing before handing back the node to the caller<br>    //  This default implementation checks a parseContent flag to optionally run the dojo parser over the new content<br>    if(this.parseContent){<br>     // populates this.parseResults if you need those..<br>     this._parse();<br>    }<br>    return this.node; /* DomNode */<br>   },<br><br> <br>   tearDown: function(){<br>    // summary<br>    //  manually reset the Setter instance if its being re-used for example for another set()<br>    // description<br>    //  tearDown() is not called automatically.<br>    //  In normal use, the Setter instance properties are simply allowed to fall out of scope<br>    //  but the tearDown method can be called to explicitly reset this instance.<br>    delete this.parseResults;<br>    delete this.node;<br>    delete this.content; </div> <li><em>returns</em><div><pre>String|DomNode</pre></div></li><li><em>summary</em><div><pre></pre></div></li></ul></li><li><h4>dojo.html._ContentSetter.onContentError</h4><ul> <li><em>type</em><div><pre>Function</pre></div></li><li><em>parameters:</em> <ul><li>err: <em>(typeof )</em><div></div></li></ul></li><li class="source"><em>source: [<a onclick="tgShow('unique8');">view</a>]</em> <div class="nosho" id="unique8">     return "Error occured setting content: " + err; </div> <li><em>summary</em><div><pre></pre></div></li></ul></li><li><h4>dojo.html._ContentSetter._mixin</h4><ul> <li><em>type</em><div><pre>Function</pre></div></li><li><em>parameters:</em> <ul><li>params: <em>(typeof )</em><div></div></li></ul></li><li class="source"><em>source: [<a onclick="tgShow('unique9');">view</a>]</em> <div class="nosho" id="unique9"> define("dojo/html", ["dojo", "dojo/parser"], function(dojo) {<br>dojo.getObject("html", true, dojo);<br><br><br>// the parser might be needed..<br>(function(){ // private scope, sort of a namespace<br><br><br> // idCounter is incremented with each instantiation to allow asignment of a unique id for tracking, logging purposes<br> var idCounter = 0,<br>  d = dojo;<br><br> <br> dojo.html._secureForInnerHtml = function(/*String*/ cont){<br>  // summary:<br>  //  removes !DOCTYPE and title elements from the html string.<br>  //<br>  //  khtml is picky about dom faults, you can't attach a style or <title> node as child of body<br>  //  must go into head, so we need to cut out those tags<br>  // cont:<br>  //  An html string for insertion into the dom<br>  //<br>  return cont.replace(/(?:\s*<!DOCTYPE\s[^>]+>|<title[^>]*>[\s\S]*?<\/title>)/ig, ""); // String<br> };<br><br><br>/*====<br> dojo.html._emptyNode = function(node){<br>  // summary:<br>  //  removes all child nodes from the given node<br>  // node: DOMNode<br>  //  the parent element<br> };<br>=====*/<br> dojo.html._emptyNode = dojo.empty;<br><br><br> dojo.html._setNodeContent = function(/* DomNode */ node, /* String|DomNode|NodeList */ cont){<br>  // summary:<br>  //  inserts the given content into the given node<br>  // node:<br>  //  the parent element<br>  // content:<br>  //  the content to be set on the parent element.<br>  //  This can be an html string, a node reference or a NodeList, dojo.NodeList, Array or other enumerable list of nodes<br><br>  <br>  // always empty<br>  d.empty(node);<br><br><br>  if(cont) {<br>   if(typeof cont == "string") {<br>    cont = d._toDom(cont, node.ownerDocument);<br>   }<br>   if(!cont.nodeType && d.isArrayLike(cont)) {<br>    // handle as enumerable, but it may shrink as we enumerate it<br>    for(var startlen=cont.length, i=0; i<cont.length; i=startlen==cont.length ? i+1 : 0) {<br>     d.place( cont[i], node, "last");<br>    }<br>   } else {<br>    // pass nodes, documentFragments and unknowns through to dojo.place<br>    d.place(cont, node, "last");<br>   }<br>  }<br><br><br>  // return DomNode<br>  return node;<br> };<br><br><br> // we wrap up the content-setting operation in a object<br> dojo.declare("dojo.html._ContentSetter", null,<br>  {<br>   // node: DomNode|String<br>   //  An node which will be the parent element that we set content into<br>   node: "",<br><br><br>   // content: String|DomNode|DomNode[]<br>   //  The content to be placed in the node. Can be an HTML string, a node reference, or a enumerable list of nodes<br>   content: "",<br><br>   <br>   // id: String?<br>   //  Usually only used internally, and auto-generated with each instance<br>   id: "",<br><br><br>   // cleanContent: Boolean<br>   //  Should the content be treated as a full html document,<br>   //  and the real content stripped of <html>, <body> wrapper before injection<br>   cleanContent: false,<br><br>   <br>   // extractContent: Boolean<br>   //  Should the content be treated as a full html document, and the real content stripped of <html>, <body> wrapper before injection<br>   extractContent: false,<br><br><br>   // parseContent: Boolean<br>   //  Should the node by passed to the parser after the new content is set<br>   parseContent: false,<br><br><br>   // parserScope: String<br>   //  Flag passed to parser. Root for attribute names to search for. If scopeName is dojo,<br>   //  will search for data-dojo-type (or dojoType). For backwards compatibility<br>   //  reasons defaults to dojo._scopeName (which is "dojo" except when<br>   //  multi-version support is used, when it will be something like dojo16, dojo20, etc.)<br>   parserScope: dojo._scopeName,<br><br><br>   // startup: Boolean<br>   //  Start the child widgets after parsing them. Only obeyed if parseContent is true.<br>   startup: true,<br><br>   <br>   // lifecyle methods<br>   constructor: function(/* Object */params, /* String|DomNode */node){<br>    // summary:<br>    //  Provides a configurable, extensible object to wrap the setting on content on a node<br>    //  call the set() method to actually set the content..<br><br> <br>    // the original params are mixed directly into the instance "this"<br>    dojo.mixin(this, params || {});<br><br><br>    // give precedence to params.node vs. the node argument<br>    // and ensure its a node, not an id string<br>    node = this.node = dojo.byId( this.node || node );<br><br> <br>    if(!this.id){<br>     this.id = [<br>      "Setter",<br>      (node) ? node.id || node.tagName : "",<br>      idCounter++<br>     ].join("_");<br>    }<br>   },<br>   set: function(/* String|DomNode|NodeList? */ cont, /* Object? */ params){<br>    // summary:<br>    //  front-end to the set-content sequence<br>    // cont:<br>    //  An html string, node or enumerable list of nodes for insertion into the dom<br>    //  If not provided, the object's content property will be used<br>    if(undefined !== cont){<br>     this.content = cont;<br>    }<br>    // in the re-use scenario, set needs to be able to mixin new configuration<br>    if(params){<br>     this._mixin(params);<br>    }<br><br><br>    this.onBegin();<br>    this.setContent();<br>    this.onEnd();<br><br><br>    return this.node;<br>   },<br>   setContent: function(){<br>    // summary:<br>    //  sets the content on the node<br><br><br>    var node = this.node;<br>    if(!node) {<br>     // can't proceed<br>     throw new Error(this.declaredClass + ": setContent given no node");<br>    }<br>    try{<br>     node = dojo.html._setNodeContent(node, this.content);<br>    }catch(e){<br>     // check if a domfault occurs when we are appending this.errorMessage<br>     // like for instance if domNode is a UL and we try append a DIV<br><br> <br>     // FIXME: need to allow the user to provide a content error message string<br>     var errMess = this.onContentError(e);<br>     try{<br>      node.innerHTML = errMess;<br>     }catch(e){<br>      console.error('Fatal ' + this.declaredClass + '.setContent could not change content due to '+e.message, e);<br>     }<br>    }<br>    // always put back the node for the next method<br>    this.node = node; // DomNode<br>   },<br><br>   <br>   empty: function() {<br>    // summary<br>    // cleanly empty out existing content<br><br><br>    // destroy any widgets from a previous run<br>    // NOTE: if you dont want this you'll need to empty<br>    // the parseResults array property yourself to avoid bad things happenning<br>    if(this.parseResults && this.parseResults.length) {<br>     dojo.forEach(this.parseResults, function(w) {<br>      if(w.destroy){<br>       w.destroy();<br>      }<br>     });<br>     delete this.parseResults;<br>    }<br>    // this is fast, but if you know its already empty or safe, you could<br>    // override empty to skip this step<br>    dojo.html._emptyNode(this.node);<br>   },<br><br> <br>   onBegin: function(){<br>    // summary<br>    //  Called after instantiation, but before set();<br>    //  It allows modification of any of the object properties<br>    //  - including the node and content provided - before the set operation actually takes place<br>    //  This default implementation checks for cleanContent and extractContent flags to<br>    //  optionally pre-process html string content<br>    var cont = this.content;<br><br> <br>    if(dojo.isString(cont)){<br>     if(this.cleanContent){<br>      cont = dojo.html._secureForInnerHtml(cont);<br>     }<br><br> <br>     if(this.extractContent){<br>      var match = cont.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im);<br>      if(match){ cont = match[1]; }<br>     }<br>    }<br><br><br>    // clean out the node and any cruft associated with it - like widgets<br>    this.empty();<br><br>    <br>    this.content = cont;<br>    return this.node; /* DomNode */<br>   },<br><br> <br>   onEnd: function(){<br>    // summary<br>    //  Called after set(), when the new content has been pushed into the node<br>    //  It provides an opportunity for post-processing before handing back the node to the caller<br>    //  This default implementation checks a parseContent flag to optionally run the dojo parser over the new content<br>    if(this.parseContent){<br>     // populates this.parseResults if you need those..<br>     this._parse();<br>    }<br>    return this.node; /* DomNode */<br>   },<br><br> <br>   tearDown: function(){<br>    // summary<br>    //  manually reset the Setter instance if its being re-used for example for another set()<br>    // description<br>    //  tearDown() is not called automatically.<br>    //  In normal use, the Setter instance properties are simply allowed to fall out of scope<br>    //  but the tearDown method can be called to explicitly reset this instance.<br>    delete this.parseResults;<br>    delete this.node;<br>    delete this.content;<br>   },<br><br> <br>   onContentError: function(err){<br>    return "Error occured setting content: " + err;<br>   },<br><br>   <br>   _mixin: function(params){<br>    // mix properties/methods into the instance<br>    // TODO: the intention with tearDown is to put the Setter's state<br>    // back to that of the original constructor (vs. deleting/resetting everything regardless of ctor params)<br>    // so we could do something here to move the original properties aside for later restoration<br>    var empty = {}, key;<br>    for(key in params){<br>     if(key in empty){ continue; }<br>     // TODO: here's our opportunity to mask the properties we dont consider configurable/overridable<br>     // .. but history shows we'll almost always guess wrong<br>     this[key] = params[key];<br>    } </div> <li><em>returns</em><div><pre>String|DomNode</pre></div></li><li><em>summary</em><div><pre></pre></div></li></ul></li><li><h4>dojo.html._ContentSetter._parse</h4><ul> <li><em>type</em><div><pre>Function</pre></div></li><li class="source"><em>source: [<a onclick="tgShow('unique10');">view</a>]</em> <div class="nosho" id="unique10">     var rootNode = this.node;<br>    try{<br>     // store the results (widgets, whatever) for potential retrieval<br>     var inherited = {};<br>     dojo.forEach(["dir", "lang", "textDir"], function(name){<br>      if(this[name]){<br>       inherited[name] = this[name];<br>      }<br>     }, this);<br>     this.parseResults = dojo.parser.parse({<br>      rootNode: rootNode,<br>      noStart: !this.startup,<br>      inherited: inherited,<br>      scope: this.parserScope<br>     });<br>    }catch(e){<br>     this._onError('Content', e, "Error parsing in _ContentSetter#"+this.id);<br>    } </div> <li><em>summary</em><div><pre>runs the dojo parser over the node contents, storing any results in this.parseResults Any errors resulting from parsing are passed to _onError for handling</pre></div></li></ul></li><li><h4>dojo.html._ContentSetter._onError</h4><ul> <li><em>type</em><div><pre>Function</pre></div></li><li><em>parameters:</em> <ul><li>type: <em>(typeof )</em><div></div></li><li>err: <em>(typeof )</em><div></div></li><li>consoleText: <em>(typeof )</em><div></div></li></ul></li><li class="source"><em>source: [<a onclick="tgShow('unique11');">view</a>]</em> <div class="nosho" id="unique11">     var errText = this['on' + type + 'Error'].call(this, err);<br>    if(consoleText){<br>     console.error(consoleText, err);<br>    }else if(errText){ // a empty string won't change current content<br>     dojo.html._setNodeContent(this.node, errText, true);<br>    } </div> <li><em>summary</em><div><pre>shows user the string that is returned by on[type]Error overide/implement on[type]Error and return your own string to customize</pre></div></li></ul></li><li><h4>dojo.html._ContentSetter.parseResults</h4><ul> <li><em>summary</em><div><pre></pre></div></li></ul></li><li><h4>d</h4><ul> <li><em>summary</em><div><pre></pre></div></li></ul></li><li><h4>dojo.html._emptyNode</h4><ul> <li><em>summary</em><div><pre></pre></div></li></ul></li><li><h4>dojo.html._secureForInnerHtml</h4><ul> <li><em>type</em><div><pre>Function</pre></div></li><li><em>parameters:</em> <ul><li>cont: <em>(typeof String)</em><div><pre>An html string for insertion into the dom</pre></div></li></ul></li><li class="source"><em>source: [<a onclick="tgShow('unique12');">view</a>]</em> <div class="nosho" id="unique12">   return cont.replace(/(?:\s*<!DOCTYPE\s[^>]+>|<title[^>]*>[\s\S]*?<\/title>)/ig, ""); // String </div> <li><em>summary</em><div><pre>removes !DOCTYPE and title elements from the html string. khtml is picky about dom faults, you can't attach a style or &lt;title&gt; node as child of body must go into head, so we need to cut out those tags</pre></div></li><li><em>returns</em><div><pre>String</pre></div></li></ul></li><li><h4>dojo.html._setNodeContent</h4><ul> <li><em>type</em><div><pre>Function</pre></div></li><li><em>parameters:</em> <ul><li>node: <em>(typeof DomNode)</em><div><pre>the parent element content: the content to be set on the parent element. This can be an html string, a node reference or a NodeList, dojo.NodeList, Array or other enumerable list of nodes always empty</pre></div></li><li>cont: <em>(typeof String|DomNode|NodeList)</em><div></div></li></ul></li><li class="source"><em>source: [<a onclick="tgShow('unique13');">view</a>]</em> <div class="nosho" id="unique13">   d.empty(node);<br><br><br>  if(cont) {<br>   if(typeof cont == "string") {<br>    cont = d._toDom(cont, node.ownerDocument);<br>   }<br>   if(!cont.nodeType && d.isArrayLike(cont)) {<br>    // handle as enumerable, but it may shrink as we enumerate it<br>    for(var startlen=cont.length, i=0; i<cont.length; i=startlen==cont.length ? i+1 : 0) {<br>     d.place( cont[i], node, "last");<br>    }<br>   } else {<br>    // pass nodes, documentFragments and unknowns through to dojo.place<br>    d.place(cont, node, "last");<br>   }<br>  }<br><br><br>  // return DomNode<br>  return node; </div> <li><em>summary</em><div><pre>inserts the given content into the given node</pre></div></li></ul></li><li><h4>dojo.html.set</h4><ul> <li><em>type</em><div><pre>Function</pre></div></li><li><em>parameters:</em> <ul><li>node: <em>(typeof DomNode)</em><div><pre>the parent element that will receive the content</pre></div></li><li>cont: <em>(typeof String|DomNode|NodeList)</em><div><pre>the content to be set on the parent element. This can be an html string, a node reference or a NodeList, dojo.NodeList, Array or other enumerable list of nodes</pre></div></li><li>params: <em>(typeof Object)</em><div><pre>Optional flags/properties to configure the content-setting. See dojo.html._ContentSetter</pre></div></li></ul></li><li class="source"><em>source: [<a onclick="tgShow('unique14');">view</a>]</em> <div class="nosho" id="unique14">   if(undefined == cont){<br>   console.warn("dojo.html.set: no cont argument provided, using empty string");<br>   cont = "";<br>  }<br>  if(!params){<br>   // simple and fast<br>   return dojo.html._setNodeContent(node, cont, true);<br>  }else{<br>   // more options but slower<br>   // note the arguments are reversed in order, to match the convention for instantiation via the parser<br>   var op = new dojo.html._ContentSetter(dojo.mixin(<br>     params,<br>     { content: cont, node: node }<br>   ));<br>   return op.set();<br>  } </div> <li><em>summary</em><div><pre>inserts (replaces) the given content into the given node. dojo.place(cont, node, &quot;only&quot;) may be a better choice for simple HTML insertion.</pre></div></li><li><em>description</em><div><pre>Unless you need to use the params capabilities of this method, you should use dojo.place(cont, node, "only"). dojo.place() has more robust support for injecting an HTML string into the DOM, but it only handles inserting an HTML string as DOM elements, or inserting a DOM node. dojo.place does not handle NodeList insertions or the other capabilities as defined by the params object for this method.</pre></div></li><li><em>example</em><div><pre>A safe string/node/nodelist content replacement/injection with hooks for extension Example Usage: dojo.html.set(node, "some string"); dojo.html.set(node, contentNode, {options}); dojo.html.set(node, myNode.childNodes, {options});</pre></div></li></ul></li><li><h4>params.content</h4><ul> <li><em>summary</em><div><pre></pre></div></li></ul></li><li><h4>params.node</h4><ul> <li><em>summary</em><div><pre></pre></div></li></ul></li><li><h4>dojo.html</h4><ul> <li><em>type</em><div><pre>Object</pre></div></li><li><em>summary</em><div><pre></pre></div></li></ul></li><li><h4>dojo</h4><ul> <li><em>type</em><div><pre>Object</pre></div></li><li><em>summary</em><div><pre></pre></div></li></ul></li></ul></div> </div> </div> </div> </body> </html>