[483] | 1 | define(["dojo/_base/kernel", "dojo/_base/lang", "dojox/xml/parser"], |
---|
| 2 | function(kernel, lang, xmlParser) { |
---|
| 3 | |
---|
| 4 | //DOM type to int value for reference. |
---|
| 5 | //Ints make for more compact code than full constant names. |
---|
| 6 | //ELEMENT_NODE = 1; |
---|
| 7 | //ATTRIBUTE_NODE = 2; |
---|
| 8 | //TEXT_NODE = 3; |
---|
| 9 | //CDATA_SECTION_NODE = 4; |
---|
| 10 | //ENTITY_REFERENCE_NODE = 5; |
---|
| 11 | //ENTITY_NODE = 6; |
---|
| 12 | //PROCESSING_INSTRUCTION_NODE = 7; |
---|
| 13 | //COMMENT_NODE = 8; |
---|
| 14 | //DOCUMENT_NODE = 9; |
---|
| 15 | //DOCUMENT_TYPE_NODE = 10; |
---|
| 16 | //DOCUMENT_FRAGMENT_NODE = 11; |
---|
| 17 | //NOTATION_NODE = 12; |
---|
| 18 | |
---|
| 19 | //This file contains internal/helper APIs as holders for people who used them. They have been migrated to |
---|
| 20 | //a better project, dojox.xml and experimental has been removed there. Please update usage to the new package. |
---|
| 21 | dojo.deprecated("dojox.data.dom", "Use dojox.xml.parser instead.", "2.0"); |
---|
| 22 | |
---|
| 23 | var dataDom = lang.getObject("dojox.data.dom",true); |
---|
| 24 | |
---|
| 25 | dataDom.createDocument = function(/*string?*/ str, /*string?*/ mimetype){ |
---|
| 26 | // summary: |
---|
| 27 | // cross-browser implementation of creating an XML document object. |
---|
| 28 | // str: |
---|
| 29 | // Optional text to create the document from. If not provided, an empty XML document will be created. |
---|
| 30 | // If str is empty string "", then a new empty document will be created. |
---|
| 31 | // mimetype: |
---|
| 32 | // Optional mimetype of the text. Typically, this is text/xml. Will be defaulted to text/xml if not provided. |
---|
| 33 | dojo.deprecated("dojox.data.dom.createDocument()", "Use dojox.xml.parser.parse() instead.", "2.0"); |
---|
| 34 | try{ |
---|
| 35 | return xmlParser.parse(str,mimetype); //DOMDocument. |
---|
| 36 | }catch(e){ |
---|
| 37 | /*Squeltch errors like the old parser did.*/ |
---|
| 38 | return null; |
---|
| 39 | } |
---|
| 40 | }; |
---|
| 41 | |
---|
| 42 | dataDom.textContent = function(/*Node*/node, /*string?*/text){ |
---|
| 43 | // summary: |
---|
| 44 | // Implementation of the DOM Level 3 attribute; scan node for text |
---|
| 45 | // description: |
---|
| 46 | // Implementation of the DOM Level 3 attribute; scan node for text |
---|
| 47 | // This function can also update the text of a node by replacing all child |
---|
| 48 | // content of the node. |
---|
| 49 | // node: |
---|
| 50 | // The node to get the text off of or set the text on. |
---|
| 51 | // text: |
---|
| 52 | // Optional argument of the text to apply to the node. |
---|
| 53 | dojo.deprecated("dojox.data.dom.textContent()", "Use dojox.xml.parser.textContent() instead.", "2.0"); |
---|
| 54 | if(arguments.length> 1){ |
---|
| 55 | return xmlParser.textContent(node, text); //string |
---|
| 56 | }else{ |
---|
| 57 | return xmlParser.textContent(node); //string |
---|
| 58 | } |
---|
| 59 | }; |
---|
| 60 | |
---|
| 61 | dataDom.replaceChildren = function(/*Element*/node, /*Node|Array*/ newChildren){ |
---|
| 62 | // summary: |
---|
| 63 | // Removes all children of node and appends newChild. All the existing |
---|
| 64 | // children will be destroyed. |
---|
| 65 | // description: |
---|
| 66 | // Removes all children of node and appends newChild. All the existing |
---|
| 67 | // children will be destroyed. |
---|
| 68 | // node: |
---|
| 69 | // The node to modify the children on |
---|
| 70 | // newChildren: |
---|
| 71 | // The children to add to the node. It can either be a single Node or an |
---|
| 72 | // array of Nodes. |
---|
| 73 | dojo.deprecated("dojox.data.dom.replaceChildren()", "Use dojox.xml.parser.replaceChildren() instead.", "2.0"); |
---|
| 74 | xmlParser.replaceChildren(node, newChildren); |
---|
| 75 | }; |
---|
| 76 | |
---|
| 77 | dataDom.removeChildren = function(/*Element*/node){ |
---|
| 78 | // summary: |
---|
| 79 | // removes all children from node and returns the count of children removed. |
---|
| 80 | // The children nodes are not destroyed. Be sure to call dojo._destroyElement on them |
---|
| 81 | // after they are not used anymore. |
---|
| 82 | // node: |
---|
| 83 | // The node to remove all the children from. |
---|
| 84 | dojo.deprecated("dojox.data.dom.removeChildren()", "Use dojox.xml.parser.removeChildren() instead.", "2.0"); |
---|
| 85 | return dojox.xml.parser.removeChildren(node); //int |
---|
| 86 | }; |
---|
| 87 | |
---|
| 88 | dataDom.innerXML = function(/*Node*/node){ |
---|
| 89 | // summary: |
---|
| 90 | // Implementation of MS's innerXML function. |
---|
| 91 | // node: |
---|
| 92 | // The node from which to generate the XML text representation. |
---|
| 93 | dojo.deprecated("dojox.data.dom.innerXML()", "Use dojox.xml.parser.innerXML() instead.", "2.0"); |
---|
| 94 | return xmlParser.innerXML(node); //string||null |
---|
| 95 | }; |
---|
| 96 | |
---|
| 97 | return dataDom; |
---|
| 98 | |
---|
| 99 | }); |
---|
| 100 | |
---|