2150 |
mathias |
1 |
if(!dojo._hasResource["dojox.wire.tests.programmatic.XmlWire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
|
|
|
2 |
dojo._hasResource["dojox.wire.tests.programmatic.XmlWire"] = true;
|
|
|
3 |
dojo.provide("dojox.wire.tests.programmatic.XmlWire");
|
|
|
4 |
|
|
|
5 |
dojo.require("dojox.wire.XmlWire");
|
|
|
6 |
|
|
|
7 |
tests.register("dojox.wire.tests.programmatic.XmlWire", [
|
|
|
8 |
|
|
|
9 |
function test_XmlWire_path(t){
|
|
|
10 |
var object = {};
|
|
|
11 |
var wire = dojox.wire.create({object: object, property: "element"});
|
|
|
12 |
new dojox.wire.XmlWire({object: wire, path: "/x/y/text()"}).setValue("Y");
|
|
|
13 |
var value = new dojox.wire.XmlWire({object: object, property: "element", path: "y/text()"}).getValue();
|
|
|
14 |
t.assertEqual("Y", value);
|
|
|
15 |
|
|
|
16 |
// attribute
|
|
|
17 |
new dojox.wire.XmlWire({object: object, property: "element", path: "y/@z"}).setValue("Z");
|
|
|
18 |
value = new dojox.wire.XmlWire({object: wire, path: "/x/y/@z"}).getValue();
|
|
|
19 |
t.assertEqual("Z", value);
|
|
|
20 |
|
|
|
21 |
// with index
|
|
|
22 |
var document = object.element.ownerDocument;
|
|
|
23 |
var element = document.createElement("y");
|
|
|
24 |
element.appendChild(document.createTextNode("Y2"));
|
|
|
25 |
object.element.appendChild(element);
|
|
|
26 |
value = new dojox.wire.XmlWire({object: object.element, path: "y[2]/text()"}).getValue();
|
|
|
27 |
t.assertEqual("Y2", value);
|
|
|
28 |
}
|
|
|
29 |
|
|
|
30 |
]);
|
|
|
31 |
|
|
|
32 |
}
|