source: Dev/branches/rest-dojo-ui/client/dojox/data/dom.js @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 3.8 KB
Line 
1define(["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.
21dojo.deprecated("dojox.data.dom", "Use dojox.xml.parser instead.", "2.0");
22
23var dataDom = lang.getObject("dojox.data.dom",true);
24
25dataDom.createDocument = function(/*string?*/ str, /*string?*/ mimetype){
26        //      summary:
27        //              cross-browser implementation of creating an XML document object.
28        //
29        //      str:
30        //              Optional text to create the document from.  If not provided, an empty XML document will be created.
31        //              If str is empty string "", then a new empty document will be created.
32        //      mimetype:
33        //              Optional mimetype of the text.  Typically, this is text/xml.  Will be defaulted to text/xml if not provided.
34        dojo.deprecated("dojox.data.dom.createDocument()", "Use dojox.xml.parser.parse() instead.", "2.0");
35        try{
36                return xmlParser.parse(str,mimetype); //DOMDocument.
37        }catch(e){
38                /*Squeltch errors like the old parser did.*/
39                return null;
40        }
41};
42
43dataDom.textContent = function(/*Node*/node, /*string?*/text){
44        //      summary:
45        //              Implementation of the DOM Level 3 attribute; scan node for text
46        //      description:
47        //              Implementation of the DOM Level 3 attribute; scan node for text
48        //              This function can also update the text of a node by replacing all child
49        //              content of the node.
50        //      node:
51        //              The node to get the text off of or set the text on.
52        //      text:
53        //              Optional argument of the text to apply to the node.
54        dojo.deprecated("dojox.data.dom.textContent()", "Use dojox.xml.parser.textContent() instead.", "2.0");
55        if(arguments.length> 1){
56                return xmlParser.textContent(node, text); //string
57        }else{
58                return xmlParser.textContent(node); //string
59        }
60};
61
62dataDom.replaceChildren = function(/*Element*/node, /*Node || array*/ newChildren){
63        //      summary:
64        //              Removes all children of node and appends newChild. All the existing
65        //              children will be destroyed.
66        //      description:
67        //              Removes all children of node and appends newChild. All the existing
68        //              children will be destroyed.
69        //      node:
70        //              The node to modify the children on
71        //      newChildren:
72        //              The children to add to the node.  It can either be a single Node or an
73        //              array of Nodes.
74        dojo.deprecated("dojox.data.dom.replaceChildren()", "Use dojox.xml.parser.replaceChildren() instead.", "2.0");
75        xmlParser.replaceChildren(node, newChildren);
76};
77
78dataDom.removeChildren = function(/*Element*/node){
79        //      summary:
80        //              removes all children from node and returns the count of children removed.
81        //              The children nodes are not destroyed. Be sure to call dojo._destroyElement on them
82        //              after they are not used anymore.
83        //      node:
84        //              The node to remove all the children from.
85        dojo.deprecated("dojox.data.dom.removeChildren()", "Use dojox.xml.parser.removeChildren() instead.", "2.0");
86        return dojox.xml.parser.removeChildren(node); //int
87};
88
89dataDom.innerXML = function(/*Node*/node){
90        //      summary:
91        //              Implementation of MS's innerXML function.
92        //      node:
93        //              The node from which to generate the XML text representation.
94        dojo.deprecated("dojox.data.dom.innerXML()", "Use dojox.xml.parser.innerXML() instead.", "2.0");
95        return xmlParser.innerXML(node); //string||null
96};
97
98return dataDom;
99
100});
101
Note: See TracBrowser for help on using the repository browser.