envjs19 0.3.8.20101029121421

Sign up to get free protection for your applications and to get access to all the features.
Files changed (279) hide show
  1. data/.jslintrbrc +30 -0
  2. data/.project +17 -0
  3. data/CHANGELOG.rdoc +57 -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 +280 -0
  14. data/README.rdoc +65 -0
  15. data/Rakefile +196 -0
  16. data/Wakefile +11 -0
  17. data/bin/envjsrb +257 -0
  18. data/build.properties +9 -0
  19. data/build.xml +247 -0
  20. data/gm/jquery.js +6002 -0
  21. data/gm/mainx.js +2648 -0
  22. data/gm/sensx.js +135 -0
  23. data/gm/t.js +6 -0
  24. data/gm/x.html +76 -0
  25. data/htmlparser/BrowserTreeBuilder.java +456 -0
  26. data/htmlparser/README +34 -0
  27. data/htmlparser/build.sh +38 -0
  28. data/jsl/jsl +0 -0
  29. data/jsl/jsl.default.conf +129 -0
  30. data/jsl/jsl.exe +0 -0
  31. data/lib/envjs.rb +35 -0
  32. data/lib/envjs/event_loop.js +206 -0
  33. data/lib/envjs/net.rb +3 -0
  34. data/lib/envjs/net/cgi.rb +94 -0
  35. data/lib/envjs/net/file.rb +69 -0
  36. data/lib/envjs/options.rb +11 -0
  37. data/lib/envjs/runtime.rb +346 -0
  38. data/lib/envjs/tempfile.rb +24 -0
  39. data/licenses/GPL-LICENSE.txt +278 -0
  40. data/licenses/MIT-LICENSE.txt +20 -0
  41. data/src/base64.js +80 -0
  42. data/src/build.js +6 -0
  43. data/src/cruft/bad.html +24 -0
  44. data/src/cruft/dom.js +606 -0
  45. data/src/cruft/element.js +297 -0
  46. data/src/cruft/good.html +30 -0
  47. data/src/cruft/good.js +32 -0
  48. data/src/cruft/internal.js +81 -0
  49. data/src/cruft/parser.js +458 -0
  50. data/src/css/properties.js +293 -0
  51. data/src/css/rule.js +22 -0
  52. data/src/css/sizzle.js +717 -0
  53. data/src/css/stylesheet.js +52 -0
  54. data/src/dom/attr.js +55 -0
  55. data/src/dom/cdatasection.js +31 -0
  56. data/src/dom/characterdata.js +119 -0
  57. data/src/dom/comment.js +30 -0
  58. data/src/dom/doctype.js +9 -0
  59. data/src/dom/document.js +1023 -0
  60. data/src/dom/dom.js +134 -0
  61. data/src/dom/element.js +217 -0
  62. data/src/dom/entities.js +273 -0
  63. data/src/dom/exception.js +28 -0
  64. data/src/dom/fragment.js +37 -0
  65. data/src/dom/implementation.js +140 -0
  66. data/src/dom/instruction.js +51 -0
  67. data/src/dom/namednodemap.js +374 -0
  68. data/src/dom/namespace.js +50 -0
  69. data/src/dom/node.js +618 -0
  70. data/src/dom/nodelist.js +195 -0
  71. data/src/dom/parser.js +1207 -0
  72. data/src/dom/text.js +73 -0
  73. data/src/event/event.js +47 -0
  74. data/src/event/mouseevent.js +4 -0
  75. data/src/event/uievent.js +8 -0
  76. data/src/html/a.js +110 -0
  77. data/src/html/anchor.js +80 -0
  78. data/src/html/area.js +57 -0
  79. data/src/html/base.js +26 -0
  80. data/src/html/blockquote-q.js +19 -0
  81. data/src/html/body.js +19 -0
  82. data/src/html/button.js +21 -0
  83. data/src/html/canvas.js +14 -0
  84. data/src/html/col-colgroup.js +49 -0
  85. data/src/html/collection.js +72 -0
  86. data/src/html/cookie.js +153 -0
  87. data/src/html/del-ins.js +25 -0
  88. data/src/html/div.js +28 -0
  89. data/src/html/document.js +364 -0
  90. data/src/html/element.js +382 -0
  91. data/src/html/fieldset.js +19 -0
  92. data/src/html/form.js +484 -0
  93. data/src/html/frame.js +89 -0
  94. data/src/html/frameset.js +25 -0
  95. data/src/html/head.js +44 -0
  96. data/src/html/html.js +0 -0
  97. data/src/html/htmlparser.js +340 -0
  98. data/src/html/iframe.js +26 -0
  99. data/src/html/image.js +0 -0
  100. data/src/html/img.js +62 -0
  101. data/src/html/input-elements.js +307 -0
  102. data/src/html/input.js +65 -0
  103. data/src/html/label.js +26 -0
  104. data/src/html/legend.js +19 -0
  105. data/src/html/link.js +82 -0
  106. data/src/html/map.js +22 -0
  107. data/src/html/meta.js +37 -0
  108. data/src/html/object.js +89 -0
  109. data/src/html/optgroup.js +25 -0
  110. data/src/html/option.js +103 -0
  111. data/src/html/param.js +38 -0
  112. data/src/html/script.js +122 -0
  113. data/src/html/select.js +132 -0
  114. data/src/html/style.js +31 -0
  115. data/src/html/table.js +199 -0
  116. data/src/html/tbody-thead-tfoot.js +92 -0
  117. data/src/html/td-th.js +18 -0
  118. data/src/html/textarea.js +31 -0
  119. data/src/html/title.js +20 -0
  120. data/src/html/tr.js +114 -0
  121. data/src/intro.js +141 -0
  122. data/src/outro.js +70 -0
  123. data/src/parser/html5.detailed.js +10762 -0
  124. data/src/parser/html5.min.js +503 -0
  125. data/src/parser/html5.pretty.js +10815 -0
  126. data/src/parser/intro.js +42 -0
  127. data/src/parser/outro.js +9 -0
  128. data/src/platform/core.js +323 -0
  129. data/src/platform/johnson.js +484 -0
  130. data/src/platform/rhino.js +327 -0
  131. data/src/platform/static/intro.js +41 -0
  132. data/src/platform/static/outro.js +30 -0
  133. data/src/profile/aop.js +238 -0
  134. data/src/profile/profile.js +402 -0
  135. data/src/serializer/xml.js +21 -0
  136. data/src/svg/animatedstring.js +25 -0
  137. data/src/svg/document.js +25 -0
  138. data/src/svg/element.js +22 -0
  139. data/src/svg/locatable.js +17 -0
  140. data/src/svg/rect.js +18 -0
  141. data/src/svg/rectelement.js +24 -0
  142. data/src/svg/stylable.js +49 -0
  143. data/src/svg/svgelement.js +22 -0
  144. data/src/svg/transformable.js +15 -0
  145. data/src/window/css.js +15 -0
  146. data/src/window/dialog.js +16 -0
  147. data/src/window/document.js +28 -0
  148. data/src/window/event.js +265 -0
  149. data/src/window/history.js +62 -0
  150. data/src/window/location.js +156 -0
  151. data/src/window/navigator.js +48 -0
  152. data/src/window/screen.js +53 -0
  153. data/src/window/timer.js +21 -0
  154. data/src/window/window.js +284 -0
  155. data/src/window/xhr.js +135 -0
  156. data/src/xpath/expression.js +49 -0
  157. data/src/xpath/implementation.js +2505 -0
  158. data/src/xpath/result.js +67 -0
  159. data/src/xpath/util.js +551 -0
  160. data/src/xpath/xmltoken.js +149 -0
  161. data/src/xslt/COPYING +34 -0
  162. data/src/xslt/ajaxslt-0.8.1/AUTHORS +1 -0
  163. data/src/xslt/ajaxslt-0.8.1/ChangeLog +136 -0
  164. data/src/xslt/ajaxslt-0.8.1/Makefile +49 -0
  165. data/src/xslt/ajaxslt-0.8.1/README +102 -0
  166. data/src/xslt/ajaxslt-0.8.1/TODO +15 -0
  167. data/src/xslt/ajaxslt-0.8.1/dom.js +566 -0
  168. data/src/xslt/ajaxslt-0.8.1/dom_unittest.html +24 -0
  169. data/src/xslt/ajaxslt-0.8.1/dom_unittest.js +131 -0
  170. data/src/xslt/ajaxslt-0.8.1/simplelog.js +79 -0
  171. data/src/xslt/ajaxslt-0.8.1/test/xpath.html +18 -0
  172. data/src/xslt/ajaxslt-0.8.1/test/xpath_script.js +45 -0
  173. data/src/xslt/ajaxslt-0.8.1/test/xslt.html +58 -0
  174. data/src/xslt/ajaxslt-0.8.1/test/xslt_script.js +33 -0
  175. data/src/xslt/ajaxslt-0.8.1/unittestsuite.html +26 -0
  176. data/src/xslt/ajaxslt-0.8.1/xmltoken.js +149 -0
  177. data/src/xslt/ajaxslt-0.8.1/xmltoken_unittest.html +18 -0
  178. data/src/xslt/ajaxslt-0.8.1/xmltoken_unittest.js +811 -0
  179. data/src/xslt/ajaxslt-0.8.1/xpath_unittest.html +39 -0
  180. data/src/xslt/ajaxslt-0.8.1/xpath_unittest.js +557 -0
  181. data/src/xslt/ajaxslt-0.8.1/xpathdebug.js +234 -0
  182. data/src/xslt/ajaxslt-0.8.1/xslt_unittest.html +138 -0
  183. data/src/xslt/ajaxslt-0.8.1/xslt_unittest.js +68 -0
  184. data/src/xslt/implementation.js +625 -0
  185. data/src/xslt/processor.js +37 -0
  186. data/src/xslt/util.js +449 -0
  187. data/test/base64.js +80 -0
  188. data/test/call-load-test.js +15 -0
  189. data/test/data.js +45 -0
  190. data/test/debug.js +53 -0
  191. data/test/firebug/errorIcon.png +0 -0
  192. data/test/firebug/firebug.css +209 -0
  193. data/test/firebug/firebug.html +23 -0
  194. data/test/firebug/firebug.js +672 -0
  195. data/test/firebug/firebugx.js +10 -0
  196. data/test/firebug/infoIcon.png +0 -0
  197. data/test/firebug/warningIcon.png +0 -0
  198. data/test/fixtures/html/events.html +171 -0
  199. data/test/fixtures/html/iframe1.html +46 -0
  200. data/test/fixtures/html/iframe1a.html +46 -0
  201. data/test/fixtures/html/iframe2.html +45 -0
  202. data/test/fixtures/html/iframe3.html +28 -0
  203. data/test/fixtures/html/iframeN.html +57 -0
  204. data/test/fixtures/html/malformed.html +181 -0
  205. data/test/fixtures/html/scope.html +81 -0
  206. data/test/fixtures/html/trivial.html +19 -0
  207. data/test/fixtures/html/with_js.html +26 -0
  208. data/test/fixtures/images/icon-blue.png +0 -0
  209. data/test/fixtures/js/external_script.js +1 -0
  210. data/test/fixtures/js/script.js +1 -0
  211. data/test/fixtures/js/script_error.js +2 -0
  212. data/test/foo.html +8 -0
  213. data/test/foo.js +40 -0
  214. data/test/html/events.html +171 -0
  215. data/test/html/iframe1.html +46 -0
  216. data/test/html/iframe1a.html +46 -0
  217. data/test/html/iframe2.html +45 -0
  218. data/test/html/iframe3.html +30 -0
  219. data/test/html/iframeN.html +57 -0
  220. data/test/html/malformed.html +181 -0
  221. data/test/html/scope.html +87 -0
  222. data/test/html/script.js +1 -0
  223. data/test/html/trivial.html +19 -0
  224. data/test/html/with_js.html +26 -0
  225. data/test/index.html +328 -0
  226. data/test/java-prototype.js +9 -0
  227. data/test/jquery.js +6002 -0
  228. data/test/primary-tests.js +26 -0
  229. data/test/prototype-test.js +13 -0
  230. data/test/qunit.js +61 -0
  231. data/test/qunit/qunit/qunit.css +17 -0
  232. data/test/qunit/qunit/qunit.js +997 -0
  233. data/test/scope.html +19 -0
  234. data/test/scope.rb +24 -0
  235. data/test/smp/dmathieu/index.html +8 -0
  236. data/test/specs/dist/env.spec.js +1534 -0
  237. data/test/specs/envjs.spec.css +46 -0
  238. data/test/specs/parser/html.js +31 -0
  239. data/test/specs/parser/spec.html +40 -0
  240. data/test/specs/parser/xml.js +31 -0
  241. data/test/specs/qunit.bdd.js +210 -0
  242. data/test/specs/qunit.css +17 -0
  243. data/test/specs/qunit.js +997 -0
  244. data/test/specs/template/spec-0.js +31 -0
  245. data/test/specs/template/spec-1.js +31 -0
  246. data/test/specs/template/spec.html +40 -0
  247. data/test/specs/window/css.js +23 -0
  248. data/test/specs/window/dialog.js +25 -0
  249. data/test/specs/window/document.js +23 -0
  250. data/test/specs/window/event.js +25 -0
  251. data/test/specs/window/history.js +34 -0
  252. data/test/specs/window/location.js +34 -0
  253. data/test/specs/window/navigator.js +71 -0
  254. data/test/specs/window/screen.js +42 -0
  255. data/test/specs/window/spec.html +48 -0
  256. data/test/specs/window/timer.js +26 -0
  257. data/test/specs/window/window.js +53 -0
  258. data/test/specs/xhr/spec.html +47 -0
  259. data/test/specs/xhr/xhr.js +31 -0
  260. data/test/test.js +10 -0
  261. data/test/unit/dom.js +44 -0
  262. data/test/unit/elementmembers.js +92 -0
  263. data/test/unit/events.js +195 -0
  264. data/test/unit/fixtures/external_script.js +1 -0
  265. data/test/unit/form.js +40 -0
  266. data/test/unit/iframe.js +234 -0
  267. data/test/unit/insertion.js +23 -0
  268. data/test/unit/multi-window.js +212 -0
  269. data/test/unit/nu.validator.js +34 -0
  270. data/test/unit/onload.js +90 -0
  271. data/test/unit/parser.js +122 -0
  272. data/test/unit/prototypecompat.js +22 -0
  273. data/test/unit/proxy.js +6 -0
  274. data/test/unit/scope.js +209 -0
  275. data/test/unit/timer.js +115 -0
  276. data/test/unit/window.js +57 -0
  277. data/test/x.js +1 -0
  278. data/test/y.js +1 -0
  279. metadata +367 -0
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @class DOMException - raised when an operation is impossible to perform
3
+ * @author Jon van Noort (jon@webarcana.com.au)
4
+ * @param code : int - the exception code (one of the DOMException constants)
5
+ */
6
+ var DOMException = function(code) {
7
+ this.code = code;
8
+ };
9
+
10
+ // DOMException constants
11
+ // Introduced in DOM Level 1:
12
+ DOMException.INDEX_SIZE_ERR = 1;
13
+ DOMException.DOMSTRING_SIZE_ERR = 2;
14
+ DOMException.HIERARCHY_REQUEST_ERR = 3;
15
+ DOMException.WRONG_DOCUMENT_ERR = 4;
16
+ DOMException.INVALID_CHARACTER_ERR = 5;
17
+ DOMException.NO_DATA_ALLOWED_ERR = 6;
18
+ DOMException.NO_MODIFICATION_ALLOWED_ERR = 7;
19
+ DOMException.NOT_FOUND_ERR = 8;
20
+ DOMException.NOT_SUPPORTED_ERR = 9;
21
+ DOMException.INUSE_ATTRIBUTE_ERR = 10;
22
+
23
+ // Introduced in DOM Level 2:
24
+ DOMException.INVALID_STATE_ERR = 11;
25
+ DOMException.SYNTAX_ERR = 12;
26
+ DOMException.INVALID_MODIFICATION_ERR = 13;
27
+ DOMException.NAMESPACE_ERR = 14;
28
+ DOMException.INVALID_ACCESS_ERR = 15;
@@ -0,0 +1,37 @@
1
+ $debug("Defining DocumentFragment");
2
+ /*
3
+ * DocumentFragment - DOM Level 2
4
+ */
5
+ /**
6
+ * @class DOMDocumentFragment - DocumentFragment is a "lightweight" or "minimal" Document object.
7
+ * @extends DOMNode
8
+ * @author Jon van Noort (jon@webarcana.com.au) and David Joham (djoham@yahoo.com)
9
+ * @param ownerDocument : DOMDocument - The Document object associated with this node.
10
+ */
11
+ var DOMDocumentFragment = function(ownerDocument) {
12
+ this.DOMNode = DOMNode;
13
+ this.DOMNode(ownerDocument);
14
+ this.nodeName = "#document-fragment";
15
+ };
16
+ DOMDocumentFragment.prototype = new DOMNode;
17
+ __extend__(DOMDocumentFragment.prototype,{
18
+ get nodeType(){
19
+ return DOMNode.DOCUMENT_FRAGMENT_NODE;
20
+ },
21
+ get xml(){
22
+ var xml = "",
23
+ count = this.childNodes.length;
24
+
25
+ // create string concatenating the serialized ChildNodes
26
+ for (var i = 0; i < count; i++) {
27
+ xml += this.childNodes.item(i).xml;
28
+ }
29
+
30
+ return xml;
31
+ },
32
+ toString : function(){
33
+ return "DocumentFragment #"+this._id;
34
+ }
35
+ });
36
+
37
+ // $w.DocumentFragment = DOMDocumentFragment;
@@ -0,0 +1,140 @@
1
+ //DOMImplementation
2
+ $debug("Defining DOMImplementation");
3
+ /**
4
+ * @class DOMImplementation - provides a number of methods for performing operations
5
+ * that are independent of any particular instance of the document object model.
6
+ *
7
+ * @author Jon van Noort (jon@webarcana.com.au)
8
+ */
9
+ var DOMImplementation = function() {
10
+ this.preserveWhiteSpace = false; // by default, ignore whitespace
11
+ this.namespaceAware = true; // by default, handle namespaces
12
+ this.errorChecking = true; // by default, test for exceptions
13
+ };
14
+
15
+ __extend__(DOMImplementation.prototype,{
16
+ // @param feature : string - The package name of the feature to test.
17
+ // the legal only values are "XML" and "CORE" (case-insensitive).
18
+ // @param version : string - This is the version number of the package
19
+ // name to test. In Level 1, this is the string "1.0".*
20
+ // @return : boolean
21
+ hasFeature : function(feature, version) {
22
+ var ret = false;
23
+ if (feature.toLowerCase() == "xml") {
24
+ ret = (!version || (version == "1.0") || (version == "2.0"));
25
+ }
26
+ else if (feature.toLowerCase() == "core") {
27
+ ret = (!version || (version == "2.0"));
28
+ }
29
+ else if (feature == "http://www.w3.org/TR/SVG11/feature#BasicStructure") {
30
+ ret = (version == "1.1");
31
+ }
32
+ return ret;
33
+ },
34
+ createDocumentType : function(qname, publicid, systemid){
35
+ return new DOMDocumentType();
36
+ },
37
+ createDocument : function(nsuri, qname, doctype){
38
+ //TODO - this currently returns an empty doc
39
+ //but needs to handle the args
40
+ return new DOMDocument(this, null);
41
+ },
42
+ createHTMLDocument : function(title){
43
+ // N.B. explict window on purpose ...
44
+ var doc = new HTMLDocument(this, window, "");
45
+ var html = doc.createElement("html"); doc.appendChild(html);
46
+ var head = doc.createElement("head"); html.appendChild(head);
47
+ var body = doc.createElement("body"); html.appendChild(body);
48
+ var t = doc.createElement("title"); head.appendChild(t);
49
+ if( title) {
50
+ t.appendChild(doc.createTextNode(title));
51
+ }
52
+ return doc;
53
+ },
54
+ translateErrCode : function(code) {
55
+ //convert DOMException Code to human readable error message;
56
+ var msg = "";
57
+
58
+ switch (code) {
59
+ case DOMException.INDEX_SIZE_ERR : // 1
60
+ msg = "INDEX_SIZE_ERR: Index out of bounds";
61
+ break;
62
+
63
+ case DOMException.DOMSTRING_SIZE_ERR : // 2
64
+ msg = "DOMSTRING_SIZE_ERR: The resulting string is too long to fit in a DOMString";
65
+ break;
66
+
67
+ case DOMException.HIERARCHY_REQUEST_ERR : // 3
68
+ msg = "HIERARCHY_REQUEST_ERR: The Node can not be inserted at this location";
69
+ break;
70
+
71
+ case DOMException.WRONG_DOCUMENT_ERR : // 4
72
+ msg = "WRONG_DOCUMENT_ERR: The source and the destination Documents are not the same";
73
+ break;
74
+
75
+ case DOMException.INVALID_CHARACTER_ERR : // 5
76
+ msg = "INVALID_CHARACTER_ERR: The string contains an invalid character";
77
+ break;
78
+
79
+ case DOMException.NO_DATA_ALLOWED_ERR : // 6
80
+ msg = "NO_DATA_ALLOWED_ERR: This Node / NodeList does not support data";
81
+ break;
82
+
83
+ case DOMException.NO_MODIFICATION_ALLOWED_ERR : // 7
84
+ msg = "NO_MODIFICATION_ALLOWED_ERR: This object cannot be modified";
85
+ break;
86
+
87
+ case DOMException.NOT_FOUND_ERR : // 8
88
+ msg = "NOT_FOUND_ERR: The item cannot be found";
89
+ break;
90
+
91
+ case DOMException.NOT_SUPPORTED_ERR : // 9
92
+ msg = "NOT_SUPPORTED_ERR: This implementation does not support function";
93
+ break;
94
+
95
+ case DOMException.INUSE_ATTRIBUTE_ERR : // 10
96
+ msg = "INUSE_ATTRIBUTE_ERR: The Attribute has already been assigned to another Element";
97
+ break;
98
+
99
+ // Introduced in DOM Level 2:
100
+ case DOMException.INVALID_STATE_ERR : // 11
101
+ msg = "INVALID_STATE_ERR: The object is no longer usable";
102
+ break;
103
+
104
+ case DOMException.SYNTAX_ERR : // 12
105
+ msg = "SYNTAX_ERR: Syntax error";
106
+ break;
107
+
108
+ case DOMException.INVALID_MODIFICATION_ERR : // 13
109
+ msg = "INVALID_MODIFICATION_ERR: Cannot change the type of the object";
110
+ break;
111
+
112
+ case DOMException.NAMESPACE_ERR : // 14
113
+ msg = "NAMESPACE_ERR: The namespace declaration is incorrect";
114
+ break;
115
+
116
+ case DOMException.INVALID_ACCESS_ERR : // 15
117
+ msg = "INVALID_ACCESS_ERR: The object does not support this function";
118
+ break;
119
+
120
+ default :
121
+ msg = "UNKNOWN: Unknown Exception Code ("+ code +")";
122
+ }
123
+
124
+ return msg;
125
+ }
126
+ });
127
+
128
+
129
+ if(false){
130
+ $debug("Initializing document.implementation");
131
+ var $implementation = new DOMImplementation();
132
+ // $implementation.namespaceAware = false;
133
+ $implementation.errorChecking = false;
134
+ }
135
+
136
+ // Local Variables:
137
+ // espresso-indent-level:4
138
+ // c-basic-offset:4
139
+ // tab-width:4
140
+ // End:
@@ -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: