envjs19 0.3.8.20101029121421
Sign up to get free protection for your applications and to get access to all the features.
- data/.jslintrbrc +30 -0
- data/.project +17 -0
- data/CHANGELOG.rdoc +57 -0
- data/DTD/xhtml-lat1.ent +196 -0
- data/DTD/xhtml-special.ent +80 -0
- data/DTD/xhtml-symbol.ent +237 -0
- data/DTD/xhtml.soc +14 -0
- data/DTD/xhtml1-frameset.dtd +1235 -0
- data/DTD/xhtml1-strict.dtd +978 -0
- data/DTD/xhtml1-transitional.dtd +1201 -0
- data/DTD/xhtml1.dcl +192 -0
- data/Makefile +7 -0
- data/Manifest.txt +280 -0
- data/README.rdoc +65 -0
- data/Rakefile +196 -0
- data/Wakefile +11 -0
- data/bin/envjsrb +257 -0
- data/build.properties +9 -0
- data/build.xml +247 -0
- data/gm/jquery.js +6002 -0
- data/gm/mainx.js +2648 -0
- data/gm/sensx.js +135 -0
- data/gm/t.js +6 -0
- data/gm/x.html +76 -0
- data/htmlparser/BrowserTreeBuilder.java +456 -0
- data/htmlparser/README +34 -0
- data/htmlparser/build.sh +38 -0
- data/jsl/jsl +0 -0
- data/jsl/jsl.default.conf +129 -0
- data/jsl/jsl.exe +0 -0
- data/lib/envjs.rb +35 -0
- data/lib/envjs/event_loop.js +206 -0
- data/lib/envjs/net.rb +3 -0
- data/lib/envjs/net/cgi.rb +94 -0
- data/lib/envjs/net/file.rb +69 -0
- data/lib/envjs/options.rb +11 -0
- data/lib/envjs/runtime.rb +346 -0
- data/lib/envjs/tempfile.rb +24 -0
- data/licenses/GPL-LICENSE.txt +278 -0
- data/licenses/MIT-LICENSE.txt +20 -0
- data/src/base64.js +80 -0
- data/src/build.js +6 -0
- data/src/cruft/bad.html +24 -0
- data/src/cruft/dom.js +606 -0
- data/src/cruft/element.js +297 -0
- data/src/cruft/good.html +30 -0
- data/src/cruft/good.js +32 -0
- data/src/cruft/internal.js +81 -0
- data/src/cruft/parser.js +458 -0
- data/src/css/properties.js +293 -0
- data/src/css/rule.js +22 -0
- data/src/css/sizzle.js +717 -0
- data/src/css/stylesheet.js +52 -0
- data/src/dom/attr.js +55 -0
- data/src/dom/cdatasection.js +31 -0
- data/src/dom/characterdata.js +119 -0
- data/src/dom/comment.js +30 -0
- data/src/dom/doctype.js +9 -0
- data/src/dom/document.js +1023 -0
- data/src/dom/dom.js +134 -0
- data/src/dom/element.js +217 -0
- data/src/dom/entities.js +273 -0
- data/src/dom/exception.js +28 -0
- data/src/dom/fragment.js +37 -0
- data/src/dom/implementation.js +140 -0
- data/src/dom/instruction.js +51 -0
- data/src/dom/namednodemap.js +374 -0
- data/src/dom/namespace.js +50 -0
- data/src/dom/node.js +618 -0
- data/src/dom/nodelist.js +195 -0
- data/src/dom/parser.js +1207 -0
- data/src/dom/text.js +73 -0
- data/src/event/event.js +47 -0
- data/src/event/mouseevent.js +4 -0
- data/src/event/uievent.js +8 -0
- data/src/html/a.js +110 -0
- data/src/html/anchor.js +80 -0
- data/src/html/area.js +57 -0
- data/src/html/base.js +26 -0
- data/src/html/blockquote-q.js +19 -0
- data/src/html/body.js +19 -0
- data/src/html/button.js +21 -0
- data/src/html/canvas.js +14 -0
- data/src/html/col-colgroup.js +49 -0
- data/src/html/collection.js +72 -0
- data/src/html/cookie.js +153 -0
- data/src/html/del-ins.js +25 -0
- data/src/html/div.js +28 -0
- data/src/html/document.js +364 -0
- data/src/html/element.js +382 -0
- data/src/html/fieldset.js +19 -0
- data/src/html/form.js +484 -0
- data/src/html/frame.js +89 -0
- data/src/html/frameset.js +25 -0
- data/src/html/head.js +44 -0
- data/src/html/html.js +0 -0
- data/src/html/htmlparser.js +340 -0
- data/src/html/iframe.js +26 -0
- data/src/html/image.js +0 -0
- data/src/html/img.js +62 -0
- data/src/html/input-elements.js +307 -0
- data/src/html/input.js +65 -0
- data/src/html/label.js +26 -0
- data/src/html/legend.js +19 -0
- data/src/html/link.js +82 -0
- data/src/html/map.js +22 -0
- data/src/html/meta.js +37 -0
- data/src/html/object.js +89 -0
- data/src/html/optgroup.js +25 -0
- data/src/html/option.js +103 -0
- data/src/html/param.js +38 -0
- data/src/html/script.js +122 -0
- data/src/html/select.js +132 -0
- data/src/html/style.js +31 -0
- data/src/html/table.js +199 -0
- data/src/html/tbody-thead-tfoot.js +92 -0
- data/src/html/td-th.js +18 -0
- data/src/html/textarea.js +31 -0
- data/src/html/title.js +20 -0
- data/src/html/tr.js +114 -0
- data/src/intro.js +141 -0
- data/src/outro.js +70 -0
- data/src/parser/html5.detailed.js +10762 -0
- data/src/parser/html5.min.js +503 -0
- data/src/parser/html5.pretty.js +10815 -0
- data/src/parser/intro.js +42 -0
- data/src/parser/outro.js +9 -0
- data/src/platform/core.js +323 -0
- data/src/platform/johnson.js +484 -0
- data/src/platform/rhino.js +327 -0
- data/src/platform/static/intro.js +41 -0
- data/src/platform/static/outro.js +30 -0
- data/src/profile/aop.js +238 -0
- data/src/profile/profile.js +402 -0
- data/src/serializer/xml.js +21 -0
- data/src/svg/animatedstring.js +25 -0
- data/src/svg/document.js +25 -0
- data/src/svg/element.js +22 -0
- data/src/svg/locatable.js +17 -0
- data/src/svg/rect.js +18 -0
- data/src/svg/rectelement.js +24 -0
- data/src/svg/stylable.js +49 -0
- data/src/svg/svgelement.js +22 -0
- data/src/svg/transformable.js +15 -0
- data/src/window/css.js +15 -0
- data/src/window/dialog.js +16 -0
- data/src/window/document.js +28 -0
- data/src/window/event.js +265 -0
- data/src/window/history.js +62 -0
- data/src/window/location.js +156 -0
- data/src/window/navigator.js +48 -0
- data/src/window/screen.js +53 -0
- data/src/window/timer.js +21 -0
- data/src/window/window.js +284 -0
- data/src/window/xhr.js +135 -0
- data/src/xpath/expression.js +49 -0
- data/src/xpath/implementation.js +2505 -0
- data/src/xpath/result.js +67 -0
- data/src/xpath/util.js +551 -0
- data/src/xpath/xmltoken.js +149 -0
- data/src/xslt/COPYING +34 -0
- data/src/xslt/ajaxslt-0.8.1/AUTHORS +1 -0
- data/src/xslt/ajaxslt-0.8.1/ChangeLog +136 -0
- data/src/xslt/ajaxslt-0.8.1/Makefile +49 -0
- data/src/xslt/ajaxslt-0.8.1/README +102 -0
- data/src/xslt/ajaxslt-0.8.1/TODO +15 -0
- data/src/xslt/ajaxslt-0.8.1/dom.js +566 -0
- data/src/xslt/ajaxslt-0.8.1/dom_unittest.html +24 -0
- data/src/xslt/ajaxslt-0.8.1/dom_unittest.js +131 -0
- data/src/xslt/ajaxslt-0.8.1/simplelog.js +79 -0
- data/src/xslt/ajaxslt-0.8.1/test/xpath.html +18 -0
- data/src/xslt/ajaxslt-0.8.1/test/xpath_script.js +45 -0
- data/src/xslt/ajaxslt-0.8.1/test/xslt.html +58 -0
- data/src/xslt/ajaxslt-0.8.1/test/xslt_script.js +33 -0
- data/src/xslt/ajaxslt-0.8.1/unittestsuite.html +26 -0
- data/src/xslt/ajaxslt-0.8.1/xmltoken.js +149 -0
- data/src/xslt/ajaxslt-0.8.1/xmltoken_unittest.html +18 -0
- data/src/xslt/ajaxslt-0.8.1/xmltoken_unittest.js +811 -0
- data/src/xslt/ajaxslt-0.8.1/xpath_unittest.html +39 -0
- data/src/xslt/ajaxslt-0.8.1/xpath_unittest.js +557 -0
- data/src/xslt/ajaxslt-0.8.1/xpathdebug.js +234 -0
- data/src/xslt/ajaxslt-0.8.1/xslt_unittest.html +138 -0
- data/src/xslt/ajaxslt-0.8.1/xslt_unittest.js +68 -0
- data/src/xslt/implementation.js +625 -0
- data/src/xslt/processor.js +37 -0
- data/src/xslt/util.js +449 -0
- data/test/base64.js +80 -0
- data/test/call-load-test.js +15 -0
- data/test/data.js +45 -0
- data/test/debug.js +53 -0
- data/test/firebug/errorIcon.png +0 -0
- data/test/firebug/firebug.css +209 -0
- data/test/firebug/firebug.html +23 -0
- data/test/firebug/firebug.js +672 -0
- data/test/firebug/firebugx.js +10 -0
- data/test/firebug/infoIcon.png +0 -0
- data/test/firebug/warningIcon.png +0 -0
- data/test/fixtures/html/events.html +171 -0
- data/test/fixtures/html/iframe1.html +46 -0
- data/test/fixtures/html/iframe1a.html +46 -0
- data/test/fixtures/html/iframe2.html +45 -0
- data/test/fixtures/html/iframe3.html +28 -0
- data/test/fixtures/html/iframeN.html +57 -0
- data/test/fixtures/html/malformed.html +181 -0
- data/test/fixtures/html/scope.html +81 -0
- data/test/fixtures/html/trivial.html +19 -0
- data/test/fixtures/html/with_js.html +26 -0
- data/test/fixtures/images/icon-blue.png +0 -0
- data/test/fixtures/js/external_script.js +1 -0
- data/test/fixtures/js/script.js +1 -0
- data/test/fixtures/js/script_error.js +2 -0
- data/test/foo.html +8 -0
- data/test/foo.js +40 -0
- data/test/html/events.html +171 -0
- data/test/html/iframe1.html +46 -0
- data/test/html/iframe1a.html +46 -0
- data/test/html/iframe2.html +45 -0
- data/test/html/iframe3.html +30 -0
- data/test/html/iframeN.html +57 -0
- data/test/html/malformed.html +181 -0
- data/test/html/scope.html +87 -0
- data/test/html/script.js +1 -0
- data/test/html/trivial.html +19 -0
- data/test/html/with_js.html +26 -0
- data/test/index.html +328 -0
- data/test/java-prototype.js +9 -0
- data/test/jquery.js +6002 -0
- data/test/primary-tests.js +26 -0
- data/test/prototype-test.js +13 -0
- data/test/qunit.js +61 -0
- data/test/qunit/qunit/qunit.css +17 -0
- data/test/qunit/qunit/qunit.js +997 -0
- data/test/scope.html +19 -0
- data/test/scope.rb +24 -0
- data/test/smp/dmathieu/index.html +8 -0
- data/test/specs/dist/env.spec.js +1534 -0
- data/test/specs/envjs.spec.css +46 -0
- data/test/specs/parser/html.js +31 -0
- data/test/specs/parser/spec.html +40 -0
- data/test/specs/parser/xml.js +31 -0
- data/test/specs/qunit.bdd.js +210 -0
- data/test/specs/qunit.css +17 -0
- data/test/specs/qunit.js +997 -0
- data/test/specs/template/spec-0.js +31 -0
- data/test/specs/template/spec-1.js +31 -0
- data/test/specs/template/spec.html +40 -0
- data/test/specs/window/css.js +23 -0
- data/test/specs/window/dialog.js +25 -0
- data/test/specs/window/document.js +23 -0
- data/test/specs/window/event.js +25 -0
- data/test/specs/window/history.js +34 -0
- data/test/specs/window/location.js +34 -0
- data/test/specs/window/navigator.js +71 -0
- data/test/specs/window/screen.js +42 -0
- data/test/specs/window/spec.html +48 -0
- data/test/specs/window/timer.js +26 -0
- data/test/specs/window/window.js +53 -0
- data/test/specs/xhr/spec.html +47 -0
- data/test/specs/xhr/xhr.js +31 -0
- data/test/test.js +10 -0
- data/test/unit/dom.js +44 -0
- data/test/unit/elementmembers.js +92 -0
- data/test/unit/events.js +195 -0
- data/test/unit/fixtures/external_script.js +1 -0
- data/test/unit/form.js +40 -0
- data/test/unit/iframe.js +234 -0
- data/test/unit/insertion.js +23 -0
- data/test/unit/multi-window.js +212 -0
- data/test/unit/nu.validator.js +34 -0
- data/test/unit/onload.js +90 -0
- data/test/unit/parser.js +122 -0
- data/test/unit/prototypecompat.js +22 -0
- data/test/unit/proxy.js +6 -0
- data/test/unit/scope.js +209 -0
- data/test/unit/timer.js +115 -0
- data/test/unit/window.js +57 -0
- data/test/x.js +1 -0
- data/test/y.js +1 -0
- 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;
|
data/src/dom/fragment.js
ADDED
@@ -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:
|