parser-args.html
1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!DOCTYPE html>
<html>
<head>
<title>Parser args Unit Test</title>
<style type="text/css">
@import "../../resources/dojo.css";
</style>
<script type="text/javascript" src="../../dojo.js" data-dojo-config="isDebug:true, async:true"></script>
<script type="text/javascript">
require(["dojo/_base/lang", "dojo/_base/declare", "doh", "dojo/parser", "dojo/domReady!"],
function(dlang, declare, doh, parser){
var mixin = dlang.mixin,
extend = dlang.extend,
exists = dlang.exists;
declare("tests.parser.Class1", null, {
constructor: function(args, node){
this.params = args;
mixin(this, args);
},
strProp1: "original1",
strProp2: "original2"
});
doh.register("args scope test", [
function noArgs(){
// Test calling parse() with no arguments.
var widgets = parser.parse();
doh.is(1, widgets.length, "found 1 widget");
doh.is("text", widgets[0].strProp1);
},
function optionsOnly(){
// Test when only the options argument is passed, and it does not contain a rootNode.
// For 2.0, if we drop scope parameter, change this test.
var widgets = parser.parse({
scope: "myscope"
});
doh.is(1, widgets.length, "found 1 widget");
doh.is("text", scopeObj.strProp1);
}
]);
doh.run();
});
</script>
</head>
<body>
<h1>Parser args Unit Test</h1>
<div data-myscope-type="tests.parser.Class1" data-myscope-id="scopeObj"
data-myscope-props="strProp1:'text'">
</div>
<div data-dojo-type="tests.parser.Class1" data-dojo-id="normalObj"
data-dojo-props="strProp1:'text'">
</div>
</body>
</html>