envjs 0.1.7 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. data/.jslintrbrc +29 -0
  2. data/.project +17 -0
  3. data/CHANGELOG.rdoc +3 -0
  4. data/DTD/xhtml-lat1.ent +196 -0
  5. data/DTD/xhtml-special.ent +80 -0
  6. data/DTD/xhtml-symbol.ent +237 -0
  7. data/DTD/xhtml.soc +14 -0
  8. data/DTD/xhtml1-frameset.dtd +1235 -0
  9. data/DTD/xhtml1-strict.dtd +978 -0
  10. data/DTD/xhtml1-transitional.dtd +1201 -0
  11. data/DTD/xhtml1.dcl +192 -0
  12. data/Makefile +7 -0
  13. data/Manifest.txt +287 -0
  14. data/{README → README.rdoc} +24 -3
  15. data/Rakefile +196 -0
  16. data/Wakefile +24 -0
  17. data/build.properties +9 -0
  18. data/build.xml +247 -0
  19. data/gm/jquery.js +6002 -0
  20. data/gm/mainx.js +2648 -0
  21. data/gm/sensx.js +135 -0
  22. data/gm/t.js +6 -0
  23. data/gm/x.html +76 -0
  24. data/htmlparser/BrowserTreeBuilder.java +456 -0
  25. data/htmlparser/README +34 -0
  26. data/htmlparser/build.sh +38 -0
  27. data/jsl/jsl +0 -0
  28. data/jsl/jsl.default.conf +129 -0
  29. data/jsl/jsl.exe +0 -0
  30. data/lib/envjs.rb +2 -0
  31. data/lib/envjs/env.js +22 -3
  32. data/lib/envjs/event_loop.js +2 -0
  33. data/lib/envjs/static.js +155 -21
  34. data/licenses/GPL-LICENSE.txt +278 -0
  35. data/licenses/MIT-LICENSE.txt +20 -0
  36. data/src/base64.js +80 -0
  37. data/src/build.js +6 -0
  38. data/src/cruft/bad.html +24 -0
  39. data/src/cruft/dom.js +606 -0
  40. data/src/cruft/element.js +297 -0
  41. data/src/cruft/good.html +30 -0
  42. data/src/cruft/good.js +32 -0
  43. data/src/cruft/internal.js +81 -0
  44. data/src/cruft/parser.js +458 -0
  45. data/src/css/properties.js +293 -0
  46. data/src/css/rule.js +22 -0
  47. data/src/css/sizzle.js +717 -0
  48. data/src/css/stylesheet.js +52 -0
  49. data/src/dom/attr.js +55 -0
  50. data/src/dom/cdatasection.js +31 -0
  51. data/src/dom/characterdata.js +119 -0
  52. data/src/dom/comment.js +30 -0
  53. data/src/dom/doctype.js +9 -0
  54. data/src/dom/document.js +553 -0
  55. data/src/dom/dom.js +134 -0
  56. data/src/dom/element.js +217 -0
  57. data/src/dom/entities.js +273 -0
  58. data/src/dom/exception.js +28 -0
  59. data/src/dom/fragment.js +37 -0
  60. data/src/dom/implementation.js +602 -0
  61. data/src/dom/instruction.js +51 -0
  62. data/src/dom/namednodemap.js +374 -0
  63. data/src/dom/namespace.js +50 -0
  64. data/src/dom/node.js +618 -0
  65. data/src/dom/nodelist.js +195 -0
  66. data/src/dom/parser.js +1207 -0
  67. data/src/dom/text.js +73 -0
  68. data/src/event/event.js +39 -0
  69. data/src/event/mouseevent.js +4 -0
  70. data/src/event/uievent.js +8 -0
  71. data/src/html/a.js +110 -0
  72. data/src/html/anchor.js +80 -0
  73. data/src/html/area.js +57 -0
  74. data/src/html/base.js +26 -0
  75. data/src/html/blockquote-q.js +19 -0
  76. data/src/html/body.js +19 -0
  77. data/src/html/button.js +21 -0
  78. data/src/html/canvas.js +14 -0
  79. data/src/html/col-colgroup.js +49 -0
  80. data/src/html/collection.js +72 -0
  81. data/src/html/cookie.js +151 -0
  82. data/src/html/del-ins.js +25 -0
  83. data/src/html/div.js +28 -0
  84. data/src/html/document.js +359 -0
  85. data/src/html/element.js +380 -0
  86. data/src/html/fieldset.js +19 -0
  87. data/src/html/form.js +484 -0
  88. data/src/html/frame.js +89 -0
  89. data/src/html/frameset.js +25 -0
  90. data/src/html/head.js +44 -0
  91. data/src/html/html.js +0 -0
  92. data/src/html/htmlparser.js +340 -0
  93. data/src/html/iframe.js +26 -0
  94. data/src/html/image.js +0 -0
  95. data/src/html/img.js +62 -0
  96. data/src/html/input-elements.js +307 -0
  97. data/src/html/input.js +65 -0
  98. data/src/html/label.js +26 -0
  99. data/src/html/legend.js +19 -0
  100. data/src/html/link.js +82 -0
  101. data/src/html/map.js +22 -0
  102. data/src/html/meta.js +37 -0
  103. data/src/html/object.js +89 -0
  104. data/src/html/optgroup.js +25 -0
  105. data/src/html/option.js +97 -0
  106. data/src/html/param.js +38 -0
  107. data/src/html/script.js +122 -0
  108. data/src/html/select.js +129 -0
  109. data/src/html/style.js +31 -0
  110. data/src/html/table.js +199 -0
  111. data/src/html/tbody-thead-tfoot.js +91 -0
  112. data/src/html/td-th.js +18 -0
  113. data/src/html/textarea.js +25 -0
  114. data/src/html/title.js +20 -0
  115. data/src/html/tr.js +114 -0
  116. data/src/intro.js +141 -0
  117. data/src/outro.js +70 -0
  118. data/src/parser/html5.detailed.js +10762 -0
  119. data/src/parser/html5.min.js +503 -0
  120. data/src/parser/html5.pretty.js +10815 -0
  121. data/src/parser/intro.js +42 -0
  122. data/src/parser/outro.js +9 -0
  123. data/src/platform/core.js +323 -0
  124. data/src/platform/johnson.js +479 -0
  125. data/src/platform/rhino.js +327 -0
  126. data/src/platform/static/intro.js +41 -0
  127. data/src/platform/static/outro.js +30 -0
  128. data/src/profile/aop.js +238 -0
  129. data/src/profile/profile.js +402 -0
  130. data/src/serializer/xml.js +21 -0
  131. data/src/svg/animatedstring.js +25 -0
  132. data/src/svg/document.js +25 -0
  133. data/src/svg/element.js +22 -0
  134. data/src/svg/locatable.js +17 -0
  135. data/src/svg/rect.js +18 -0
  136. data/src/svg/rectelement.js +24 -0
  137. data/src/svg/stylable.js +49 -0
  138. data/src/svg/svgelement.js +22 -0
  139. data/src/svg/transformable.js +15 -0
  140. data/src/window/css.js +15 -0
  141. data/src/window/dialog.js +16 -0
  142. data/src/window/document.js +28 -0
  143. data/src/window/event.js +262 -0
  144. data/src/window/history.js +62 -0
  145. data/src/window/location.js +138 -0
  146. data/src/window/navigator.js +48 -0
  147. data/src/window/screen.js +53 -0
  148. data/src/window/timer.js +21 -0
  149. data/src/window/window.js +284 -0
  150. data/src/window/xhr.js +127 -0
  151. data/src/xpath/expression.js +49 -0
  152. data/src/xpath/implementation.js +2482 -0
  153. data/src/xpath/result.js +67 -0
  154. data/src/xpath/util.js +551 -0
  155. data/src/xpath/xmltoken.js +149 -0
  156. data/src/xslt/COPYING +34 -0
  157. data/src/xslt/ajaxslt-0.8.1/AUTHORS +1 -0
  158. data/src/xslt/ajaxslt-0.8.1/ChangeLog +136 -0
  159. data/src/xslt/ajaxslt-0.8.1/Makefile +49 -0
  160. data/src/xslt/ajaxslt-0.8.1/README +102 -0
  161. data/src/xslt/ajaxslt-0.8.1/TODO +15 -0
  162. data/src/xslt/ajaxslt-0.8.1/dom.js +566 -0
  163. data/src/xslt/ajaxslt-0.8.1/dom_unittest.html +24 -0
  164. data/src/xslt/ajaxslt-0.8.1/dom_unittest.js +131 -0
  165. data/src/xslt/ajaxslt-0.8.1/simplelog.js +79 -0
  166. data/src/xslt/ajaxslt-0.8.1/test/xpath.html +18 -0
  167. data/src/xslt/ajaxslt-0.8.1/test/xpath_script.js +45 -0
  168. data/src/xslt/ajaxslt-0.8.1/test/xslt.html +58 -0
  169. data/src/xslt/ajaxslt-0.8.1/test/xslt_script.js +33 -0
  170. data/src/xslt/ajaxslt-0.8.1/unittestsuite.html +26 -0
  171. data/src/xslt/ajaxslt-0.8.1/xmltoken.js +149 -0
  172. data/src/xslt/ajaxslt-0.8.1/xmltoken_unittest.html +18 -0
  173. data/src/xslt/ajaxslt-0.8.1/xmltoken_unittest.js +811 -0
  174. data/src/xslt/ajaxslt-0.8.1/xpath_unittest.html +39 -0
  175. data/src/xslt/ajaxslt-0.8.1/xpath_unittest.js +557 -0
  176. data/src/xslt/ajaxslt-0.8.1/xpathdebug.js +234 -0
  177. data/src/xslt/ajaxslt-0.8.1/xslt_unittest.html +138 -0
  178. data/src/xslt/ajaxslt-0.8.1/xslt_unittest.js +68 -0
  179. data/src/xslt/implementation.js +625 -0
  180. data/src/xslt/processor.js +37 -0
  181. data/src/xslt/util.js +449 -0
  182. data/test/foo.html +8 -0
  183. data/test/foo.js +40 -0
  184. data/test/jquery.js +6002 -0
  185. data/test/x.js +1 -0
  186. data/test/y.js +1 -0
  187. metadata +245 -14
@@ -0,0 +1,51 @@
1
+ $debug("Defining ProcessingInstruction");
2
+ /*
3
+ * ProcessingInstruction - DOM Level 2
4
+ */
5
+ /**
6
+ * @class DOMProcessingInstruction - The ProcessingInstruction interface represents a "processing instruction",
7
+ * used in XML as a way to keep processor-specific information in the text of the document
8
+ * @extends DOMNode
9
+ * @author Jon van Noort (jon@webarcana.com.au)
10
+ * @param ownerDocument : DOMDocument - The Document object associated with this node.
11
+ */
12
+ var DOMProcessingInstruction = function(ownerDocument) {
13
+ this.DOMNode = DOMNode;
14
+ this.DOMNode(ownerDocument);
15
+ };
16
+ DOMProcessingInstruction.prototype = new DOMNode;
17
+ __extend__(DOMProcessingInstruction.prototype, {
18
+ get data(){
19
+ return this.nodeValue;
20
+ },
21
+ set data(data){
22
+ // throw Exception if DOMNode is readonly
23
+ if (__ownerDocument__(this).errorChecking && this._readonly) {
24
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
25
+ }
26
+ this.nodeValue = data;
27
+ },
28
+ get target(){
29
+ // The target of this processing instruction.
30
+ // XML defines this as being the first token following the markup that begins the processing instruction.
31
+ // The content of this processing instruction.
32
+ return this.nodeName;
33
+ },
34
+ set target(value){
35
+ // The target of this processing instruction.
36
+ // XML defines this as being the first token following the markup that begins the processing instruction.
37
+ // The content of this processing instruction.
38
+ this.nodeName = value;
39
+ },
40
+ get nodeType(){
41
+ return DOMNode.PROCESSING_INSTRUCTION_NODE;
42
+ },
43
+ get xml(){
44
+ return "<?" + this.nodeName +" "+ this.nodeValue + " ?>";
45
+ },
46
+ toString : function(){
47
+ return "ProcessingInstruction #"+this._id;
48
+ }
49
+ });
50
+
51
+ // $w.ProcessesingInstruction = DOMProcessingInstruction;
@@ -0,0 +1,374 @@
1
+ /**
2
+ * @class DOMNamedNodeMap - used to represent collections of nodes that can be accessed by name
3
+ * typically a set of Element attributes
4
+ *
5
+ * @extends DOMNodeList - note W3C spec says that this is not the case,
6
+ * but we need an item() method identicle to DOMNodeList's, so why not?
7
+ * @author Jon van Noort (jon@webarcana.com.au)
8
+ * @param ownerDocument : DOMDocument - the ownerDocument
9
+ * @param parentNode : DOMNode - the node that the DOMNamedNodeMap is attached to (or null)
10
+ */
11
+ var DOMNamedNodeMap = function(ownerDocument, parentNode) {
12
+ //$log("\t\tcreating dom namednodemap");
13
+ this.DOMNodeList = DOMNodeList;
14
+ this.DOMNodeList(ownerDocument, parentNode);
15
+ __setArray__(this, []);
16
+ };
17
+ DOMNamedNodeMap.prototype = new DOMNodeList;
18
+ __extend__(DOMNamedNodeMap.prototype, {
19
+ add: function(name){
20
+ this[this.length] = name;
21
+ },
22
+ getNamedItem : function(name) {
23
+ var ret = null;
24
+
25
+ // test that Named Node exists
26
+ var itemIndex = __findNamedItemIndex__(this, name);
27
+
28
+ if (itemIndex > -1) { // found it!
29
+ ret = this[itemIndex]; // return NamedNode
30
+ }
31
+
32
+ return ret; // if node is not found, default value null is returned
33
+ },
34
+ setNamedItem : function(arg) {
35
+ // test for exceptions
36
+ if (__ownerDocument__(this).implementation.errorChecking) {
37
+ // throw Exception if arg was not created by this Document
38
+ if (this.ownerDocument != arg.ownerDocument) {
39
+ throw(new DOMException(DOMException.WRONG_DOCUMENT_ERR));
40
+ }
41
+
42
+ // throw Exception if DOMNamedNodeMap is readonly
43
+ if (this._readonly || (this.parentNode && this.parentNode._readonly)) {
44
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
45
+ }
46
+
47
+ // throw Exception if arg is already an attribute of another Element object
48
+ if (arg.ownerElement && (arg.ownerElement != this.parentNode)) {
49
+ throw(new DOMException(DOMException.INUSE_ATTRIBUTE_ERR));
50
+ }
51
+ }
52
+
53
+ // get item index
54
+ var itemIndex = __findNamedItemIndex__(this, arg.name);
55
+ var ret = null;
56
+
57
+ if (itemIndex > -1) { // found it!
58
+ ret = this[itemIndex]; // use existing Attribute
59
+
60
+ // throw Exception if DOMAttr is readonly
61
+ if (__ownerDocument__(this).implementation.errorChecking && ret._readonly) {
62
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
63
+ } else {
64
+ this[itemIndex] = arg; // over-write existing NamedNode
65
+ this[arg.name.toLowerCase()] = arg;
66
+ }
67
+ } else {
68
+ // add new NamedNode
69
+ Array.prototype.push.apply(this, [arg]);
70
+ this[arg.name.toLowerCase()] = arg;
71
+ }
72
+
73
+ arg.ownerElement = this.parentNode; // update ownerElement
74
+
75
+ return ret; // return old node or null
76
+ },
77
+ removeNamedItem : function(name) {
78
+ var ret = null;
79
+ // test for exceptions
80
+ // throw Exception if DOMNamedNodeMap is readonly
81
+ if (__ownerDocument__(this).implementation.errorChecking &&
82
+ (this._readonly || (this.parentNode && this.parentNode._readonly))) {
83
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
84
+ }
85
+
86
+ // get item index
87
+ var itemIndex = __findNamedItemIndex__(this, name);
88
+
89
+ // throw Exception if there is no node named name in this map
90
+ if (__ownerDocument__(this).implementation.errorChecking && (itemIndex < 0)) {
91
+ throw(new DOMException(DOMException.NOT_FOUND_ERR));
92
+ }
93
+
94
+ // get Node
95
+ var oldNode = this[itemIndex];
96
+ //this[oldNode.name] = undefined;
97
+
98
+ // throw Exception if Node is readonly
99
+ if (__ownerDocument__(this).implementation.errorChecking && oldNode._readonly) {
100
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
101
+ }
102
+
103
+ // return removed node
104
+ return __removeChild__(this, itemIndex);
105
+ },
106
+ getNamedItemNS : function(namespaceURI, localName) {
107
+ var ret = null;
108
+
109
+ // test that Named Node exists
110
+ var itemIndex = __findNamedItemNSIndex__(this, namespaceURI, localName);
111
+
112
+ if (itemIndex > -1) { // found it!
113
+ ret = this[itemIndex]; // return NamedNode
114
+ }
115
+
116
+ return ret; // if node is not found, default value null is returned
117
+ },
118
+ setNamedItemNS : function(arg) {
119
+ // test for exceptions
120
+ if (__ownerDocument__(this).implementation.errorChecking) {
121
+ // throw Exception if DOMNamedNodeMap is readonly
122
+ if (this._readonly || (this.parentNode && this.parentNode._readonly)) {
123
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
124
+ }
125
+
126
+ // throw Exception if arg was not created by this Document
127
+ if (__ownerDocument__(this) != __ownerDocument__(arg)) {
128
+ throw(new DOMException(DOMException.WRONG_DOCUMENT_ERR));
129
+ }
130
+
131
+ // throw Exception if arg is already an attribute of another Element object
132
+ if (arg.ownerElement && (arg.ownerElement != this.parentNode)) {
133
+ throw(new DOMException(DOMException.INUSE_ATTRIBUTE_ERR));
134
+ }
135
+ }
136
+
137
+ // get item index
138
+ var itemIndex = __findNamedItemNSIndex__(this, arg.namespaceURI, arg.localName);
139
+ var ret = null;
140
+
141
+ if (itemIndex > -1) { // found it!
142
+ ret = this[itemIndex]; // use existing Attribute
143
+ // throw Exception if DOMAttr is readonly
144
+ if (__ownerDocument__(this).implementation.errorChecking && ret._readonly) {
145
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
146
+ } else {
147
+ this[itemIndex] = arg; // over-write existing NamedNode
148
+ this[arg.name.toLowerCase()] = arg;
149
+ }
150
+ }else {
151
+ // add new NamedNode
152
+ Array.prototype.push.apply(this, [arg]);
153
+ this[arg.name.toLowerCase()] = arg;
154
+ }
155
+ arg.ownerElement = this.parentNode;
156
+
157
+
158
+ return ret; // return old node or null
159
+ },
160
+ removeNamedItemNS : function(namespaceURI, localName) {
161
+ var ret = null;
162
+
163
+ // test for exceptions
164
+ // throw Exception if DOMNamedNodeMap is readonly
165
+ if (__ownerDocument__(this).implementation.errorChecking && (this._readonly || (this.parentNode && this.parentNode._readonly))) {
166
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
167
+ }
168
+
169
+ // get item index
170
+ var itemIndex = __findNamedItemNSIndex__(this, namespaceURI, localName);
171
+
172
+ // throw Exception if there is no matching node in this map
173
+ if (__ownerDocument__(this).implementation.errorChecking && (itemIndex < 0)) {
174
+ throw(new DOMException(DOMException.NOT_FOUND_ERR));
175
+ }
176
+
177
+ // get Node
178
+ var oldNode = this[itemIndex];
179
+
180
+ // throw Exception if Node is readonly
181
+ if (__ownerDocument__(this).implementation.errorChecking && oldNode._readonly) {
182
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
183
+ }
184
+
185
+ return __removeChild__(this, itemIndex); // return removed node
186
+ },
187
+ get xml() {
188
+ var ret = "";
189
+
190
+ // create string containing concatenation of all (but last) Attribute string values (separated by spaces)
191
+ for (var i=0; i < this.length -1; i++) {
192
+ ret += this[i].xml +" ";
193
+ }
194
+
195
+ // add last Attribute to string (without trailing space)
196
+ if (this.length > 0) {
197
+ ret += this[this.length -1].xml;
198
+ }
199
+
200
+ return ret;
201
+ }
202
+
203
+ });
204
+
205
+ /**
206
+ * @method DOMNamedNodeMap._findNamedItemIndex - find the item index of the node with the specified name
207
+ *
208
+ * @author Jon van Noort (jon@webarcana.com.au)
209
+ * @param name : string - the name of the required node
210
+ * @return : int
211
+ */
212
+ var __findNamedItemIndex__ = function(namednodemap, name) {
213
+ var ret = -1;
214
+
215
+ // loop through all nodes
216
+ for (var i=0; i<namednodemap.length; i++) {
217
+ // compare name to each node's nodeName
218
+ if(namednodemap.isnsmap){
219
+ if (namednodemap[i].localName.toLowerCase() == name.toLowerCase()) { // found it!
220
+ ret = i;
221
+ break;
222
+ }
223
+ }else{
224
+ if (namednodemap[i].name.toLowerCase() == name.toLowerCase()) { // found it!
225
+ ret = i;
226
+ break;
227
+ }
228
+ }
229
+ }
230
+
231
+ return ret; // if node is not found, default value -1 is returned
232
+ };
233
+
234
+ /**
235
+ * @method DOMNamedNodeMap._findNamedItemNSIndex - find the item index of the node with the specified namespaceURI and localName
236
+ *
237
+ * @author Jon van Noort (jon@webarcana.com.au)
238
+ * @param namespaceURI : string - the namespace URI of the required node
239
+ * @param localName : string - the local name of the required node
240
+ * @return : int
241
+ */
242
+ var __findNamedItemNSIndex__ = function(namednodemap, namespaceURI, localName) {
243
+ var ret = -1;
244
+
245
+ // test that localName is not null
246
+ if (localName) {
247
+ // loop through all nodes
248
+ for (var i=0; i<namednodemap.length; i++) {
249
+ // compare name to each node's namespaceURI and localName
250
+ if ((namednodemap[i].namespaceURI.toLowerCase() == namespaceURI.toLowerCase()) &&
251
+ (namednodemap[i].localName.toLowerCase() == localName.toLowerCase())) {
252
+ ret = i; // found it!
253
+ break;
254
+ }
255
+ }
256
+ }
257
+
258
+ return ret; // if node is not found, default value -1 is returned
259
+ };
260
+
261
+ /**
262
+ * @method DOMNamedNodeMap._hasAttribute - Returns true if specified node exists
263
+ *
264
+ * @author Jon van Noort (jon@webarcana.com.au)
265
+ * @param name : string - the name of the required node
266
+ * @return : boolean
267
+ */
268
+ var __hasAttribute__ = function(namednodemap, name) {
269
+ var ret = false;
270
+
271
+ // test that Named Node exists
272
+ var itemIndex = __findNamedItemIndex__(namednodemap, name);
273
+
274
+ if (itemIndex > -1) { // found it!
275
+ ret = true; // return true
276
+ }
277
+
278
+ return ret; // if node is not found, default value false is returned
279
+ }
280
+
281
+ /**
282
+ * @method DOMNamedNodeMap._hasAttributeNS - Returns true if specified node exists
283
+ *
284
+ * @author Jon van Noort (jon@webarcana.com.au)
285
+ * @param namespaceURI : string - the namespace URI of the required node
286
+ * @param localName : string - the local name of the required node
287
+ * @return : boolean
288
+ */
289
+ var __hasAttributeNS__ = function(namednodemap, namespaceURI, localName) {
290
+ var ret = false;
291
+
292
+ // test that Named Node exists
293
+ var itemIndex = __findNamedItemNSIndex__(namednodemap, namespaceURI, localName);
294
+
295
+ if (itemIndex > -1) { // found it!
296
+ ret = true; // return true
297
+ }
298
+
299
+ return ret; // if node is not found, default value false is returned
300
+ }
301
+
302
+ /**
303
+ * @method DOMNamedNodeMap._cloneNodes - Returns a NamedNodeMap containing clones of the Nodes in this NamedNodeMap
304
+ *
305
+ * @author Jon van Noort (jon@webarcana.com.au)
306
+ * @param parentNode : DOMNode - the new parent of the cloned NodeList
307
+ * @param isnsmap : bool - is this a DOMNamespaceNodeMap
308
+ * @return : DOMNamedNodeMap - NamedNodeMap containing clones of the Nodes in this DOMNamedNodeMap
309
+ */
310
+ var __cloneNamedNodes__ = function(namednodemap, parentNode) {
311
+ var cloneNamedNodeMap = namednodemap.isnsmap?
312
+ new DOMNamespaceNodeMap(namednodemap.ownerDocument, parentNode):
313
+ new DOMNamedNodeMap(namednodemap.ownerDocument, parentNode);
314
+
315
+ // create list containing clones of all children
316
+ for (var i=0; i < namednodemap.length; i++) {
317
+ $debug("cloning node in named node map :" + namednodemap[i]);
318
+ __appendChild__(cloneNamedNodeMap, namednodemap[i].cloneNode(false));
319
+ }
320
+
321
+ return cloneNamedNodeMap;
322
+ };
323
+
324
+
325
+ /**
326
+ * @class DOMNamespaceNodeMap - used to represent collections of namespace nodes that can be accessed by name
327
+ * typically a set of Element attributes
328
+ *
329
+ * @extends DOMNamedNodeMap
330
+ *
331
+ * @author Jon van Noort (jon@webarcana.com.au)
332
+ *
333
+ * @param ownerDocument : DOMDocument - the ownerDocument
334
+ * @param parentNode : DOMNode - the node that the DOMNamespaceNodeMap is attached to (or null)
335
+ */
336
+ var DOMNamespaceNodeMap = function(ownerDocument, parentNode) {
337
+ //$log("\t\t\tcreating dom namespacednodemap");
338
+ this.DOMNamedNodeMap = DOMNamedNodeMap;
339
+ this.DOMNamedNodeMap(ownerDocument, parentNode);
340
+ __setArray__(this, []);
341
+ this.isnsmap = true;
342
+ };
343
+ DOMNamespaceNodeMap.prototype = new DOMNamedNodeMap;
344
+ __extend__(DOMNamespaceNodeMap.prototype, {
345
+ get xml() {
346
+ var ret = "";
347
+
348
+ // identify namespaces declared local to this Element (ie, not inherited)
349
+ for (var ind = 0; ind < this.length; ind++) {
350
+ // if namespace declaration does not exist in the containing node's, parentNode's namespaces
351
+ var ns = null;
352
+ try {
353
+ var ns = this.parentNode.parentNode._namespaces.
354
+ getNamedItem(this[ind].localName);
355
+ }
356
+ catch (e) {
357
+ //breaking to prevent default namespace being inserted into return value
358
+ break;
359
+ }
360
+ if (!(ns && (""+ ns.nodeValue == ""+ this[ind].nodeValue))) {
361
+ // display the namespace declaration
362
+ ret += this[ind].xml +" ";
363
+ }
364
+ }
365
+
366
+ return ret;
367
+ }
368
+ });
369
+
370
+ // Local Variables:
371
+ // espresso-indent-level:4
372
+ // c-basic-offset:4
373
+ // tab-width:4
374
+ // End:
@@ -0,0 +1,50 @@
1
+
2
+ /**
3
+ * @class DOMNamespace - The Namespace interface represents an namespace in an Element object
4
+ *
5
+ * @extends DOMNode
6
+ * @author Jon van Noort (jon@webarcana.com.au)
7
+ * @param ownerDocument : DOMDocument - The Document object associated with this node.
8
+ */
9
+ var DOMNamespace = function(ownerDocument) {
10
+ this.DOMNode = DOMNode;
11
+ this.DOMNode(ownerDocument);
12
+
13
+ this.name = ""; // the name of this attribute
14
+
15
+ // If this attribute was explicitly given a value in the original document, this is true; otherwise, it is false.
16
+ // Note that the implementation is in charge of this attribute, not the user.
17
+ // If the user changes the value of the attribute (even if it ends up having the same value as the default value)
18
+ // then the specified flag is automatically flipped to true
19
+ this.specified = false;
20
+ };
21
+ DOMNamespace.prototype = new DOMNode;
22
+ __extend__(DOMNamespace.prototype, {
23
+ get value(){
24
+ // the value of the attribute is returned as a string
25
+ return this.nodeValue;
26
+ },
27
+ set value(value){
28
+ this.nodeValue = value+'';
29
+ },
30
+ get nodeType(){
31
+ return DOMNode.NAMESPACE_NODE;
32
+ },
33
+ get xml(){
34
+ var ret = "";
35
+
36
+ // serialize Namespace Declaration
37
+ if (this.name != "") {
38
+ ret += this.name +"=\""+ __escapeXML__(this.nodeValue) +"\"";
39
+ }
40
+ else { // handle default namespace
41
+ ret += "xmlns=\""+ __escapeXML__(this.nodeValue) +"\"";
42
+ }
43
+
44
+ return ret;
45
+ },
46
+ toString: function(){
47
+ return "Namespace " + this.name + "=" + this.value;
48
+ }
49
+ });
50
+