widgetParser.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //>>built
  2. define("dojox/xml/widgetParser",["dojo/_base/lang","dojo/_base/window","dojo/_base/sniff","dojo/query","dojo/parser","dojox/xml/parser"],function(_1,_2,_3,_4,_5,_6){
  3. var _7=lang.getObject("dojox.xml",true);
  4. xXml.widgetParser=new function(){
  5. var d=_1;
  6. this.parseNode=function(_8){
  7. var _9=[];
  8. d.query("script[type='text/xml']",_8).forEach(function(_a){
  9. _9.push.apply(_9,this._processScript(_a));
  10. },this).orphan();
  11. return d.parser.instantiate(_9);
  12. };
  13. this._processScript=function(_b){
  14. var _c=_b.src?d._getText(_b.src):_b.innerHTML||_b.firstChild.nodeValue;
  15. var _d=this.toHTML(dojox.xml.parser.parse(_c).firstChild);
  16. var _e=d.query("[dojoType]",_d);
  17. _4(">",_d).place(_b,"before");
  18. _b.parentNode.removeChild(_b);
  19. return _e;
  20. };
  21. this.toHTML=function(_f){
  22. var _10;
  23. var _11=_f.nodeName;
  24. var dd=_2.doc;
  25. var _12=_f.nodeType;
  26. if(_12>=3){
  27. return dd.createTextNode((_12==3||_12==4)?_f.nodeValue:"");
  28. }
  29. var _13=_f.localName||_11.split(":").pop();
  30. var _14=_f.namespaceURI||(_f.getNamespaceUri?_f.getNamespaceUri():"");
  31. if(_14=="html"){
  32. _10=dd.createElement(_13);
  33. }else{
  34. var _15=_14+"."+_13;
  35. _10=_10||dd.createElement((_15=="dijit.form.ComboBox")?"select":"div");
  36. _10.setAttribute("dojoType",_15);
  37. }
  38. d.forEach(_f.attributes,function(_16){
  39. var _17=_16.name||_16.nodeName;
  40. var _18=_16.value||_16.nodeValue;
  41. if(_17.indexOf("xmlns")!=0){
  42. if(_3("ie")&&_17=="style"){
  43. _10.style.setAttribute("cssText",_18);
  44. }else{
  45. _10.setAttribute(_17,_18);
  46. }
  47. }
  48. });
  49. d.forEach(_f.childNodes,function(cn){
  50. var _19=this.toHTML(cn);
  51. if(_13=="script"){
  52. _10.text+=_19.nodeValue;
  53. }else{
  54. _10.appendChild(_19);
  55. }
  56. },this);
  57. return _10;
  58. };
  59. }();
  60. return _7.widgetParser;
  61. });