envjs 0.1.7 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.jslintrbrc +29 -0
- data/.project +17 -0
- data/CHANGELOG.rdoc +3 -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 +287 -0
- data/{README → README.rdoc} +24 -3
- data/Rakefile +196 -0
- data/Wakefile +24 -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 +2 -0
- data/lib/envjs/env.js +22 -3
- data/lib/envjs/event_loop.js +2 -0
- data/lib/envjs/static.js +155 -21
- 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 +553 -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 +602 -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 +39 -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 +151 -0
- data/src/html/del-ins.js +25 -0
- data/src/html/div.js +28 -0
- data/src/html/document.js +359 -0
- data/src/html/element.js +380 -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 +97 -0
- data/src/html/param.js +38 -0
- data/src/html/script.js +122 -0
- data/src/html/select.js +129 -0
- data/src/html/style.js +31 -0
- data/src/html/table.js +199 -0
- data/src/html/tbody-thead-tfoot.js +91 -0
- data/src/html/td-th.js +18 -0
- data/src/html/textarea.js +25 -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 +479 -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 +262 -0
- data/src/window/history.js +62 -0
- data/src/window/location.js +138 -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 +127 -0
- data/src/xpath/expression.js +49 -0
- data/src/xpath/implementation.js +2482 -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/foo.html +8 -0
- data/test/foo.js +40 -0
- data/test/jquery.js +6002 -0
- data/test/x.js +1 -0
- data/test/y.js +1 -0
- 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
|
+
|