DomInline.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. define("dojox/dtl/DomInline", [
  2. "dojo/_base/lang",
  3. "./dom",
  4. "./_base",
  5. "dijit/_WidgetBase"
  6. ], function(lang,ddd,dd,Widget){
  7. /*=====
  8. dd = dojox.dtl;
  9. Widget = dijit._WidgetBase;
  10. =====*/
  11. dd.DomInline = lang.extend(function(args, node){
  12. this.create(args, node);
  13. },
  14. Widget.prototype,
  15. {
  16. context: null,
  17. render: function(/*dojox.dtl.Context?*/ context){
  18. this.context = context || this.context;
  19. this.postMixInProperties();
  20. var root = this.template.render(this.context).getRootNode();
  21. if(root != this.containerNode){
  22. this.containerNode.parentNode.replaceChild(root, this.containerNode);
  23. this.containerNode = root;
  24. }
  25. },
  26. declaredClass: "dojox.dtl.Inline",
  27. buildRendering: function(){
  28. var div = this.domNode = document.createElement("div");
  29. this.containerNode = div.appendChild(document.createElement("div"));
  30. var node = this.srcNodeRef;
  31. if(node.parentNode){
  32. node.parentNode.replaceChild(div, node);
  33. }
  34. this.template = new dojox.dtl.DomTemplate(lang.trim(node.text), true);
  35. this.render();
  36. },
  37. postMixInProperties: function(){
  38. this.context = (this.context.get === dojox.dtl._Context.prototype.get) ? this.context : new dojox.dtl.Context(this.context);
  39. }
  40. });
  41. return dojox.dtl.DomInline;
  42. });