1 | <html> |
---|
2 | <head> |
---|
3 | <script type="text/javascript"> |
---|
4 | dojoConfig= { |
---|
5 | someConfigSwitch:0, |
---|
6 | isDebug:1, |
---|
7 | has:{ |
---|
8 | "some-has-feature":5 |
---|
9 | } |
---|
10 | } |
---|
11 | </script> |
---|
12 | <script type="text/javascript" src="../../../dojo.js" data-dojo-config="anotherConfigSwitch:2"></script> |
---|
13 | <script type="text/javascript"> |
---|
14 | require(["doh", "dojo/has"], function(doh, has) { |
---|
15 | doh.register("config-has", [ |
---|
16 | function check1(t) { |
---|
17 | t.is(require.rawConfig.someConfigSwitch, 0); |
---|
18 | t.is(require.rawConfig.isDebug, 1); |
---|
19 | t.is(require.rawConfig.anotherConfigSwitch, 2); |
---|
20 | |
---|
21 | t.is(has("config-someConfigSwitch"), 0); |
---|
22 | t.is(has("config-isDebug"), 1); |
---|
23 | t.is(has("config-anotherConfigSwitch"), 2); |
---|
24 | t.is(has("some-has-feature"), 5); |
---|
25 | |
---|
26 | // setting an existing config variable after boot does *not* affect the has cache |
---|
27 | require({someConfigSwitch:3}); |
---|
28 | t.is(require.rawConfig.someConfigSwitch, 3); |
---|
29 | t.is(has("config-someConfigSwitch"), 0); |
---|
30 | |
---|
31 | // but, we can add new configfeatures any time |
---|
32 | require({someNewConfigSwitch:4}); |
---|
33 | t.is(require.rawConfig.someNewConfigSwitch, 4); |
---|
34 | t.is(has("config-someNewConfigSwitch"), 4); |
---|
35 | |
---|
36 | // setting an existing has feature via config after boot does *not* affect the has cache |
---|
37 | require({has:{"some-has-feature":6}}); |
---|
38 | t.is(has("some-has-feature"), 5); |
---|
39 | |
---|
40 | // setting an existing has feature via has.add does *not* affect the has cache... |
---|
41 | has.add("some-has-feature", 6); |
---|
42 | t.is(has("some-has-feature"), 5); |
---|
43 | |
---|
44 | // ...*unless* you use force... |
---|
45 | has.add("some-has-feature", 6, 0, 1); |
---|
46 | t.is(has("some-has-feature"), 6); |
---|
47 | |
---|
48 | // but, we can add new has features any time |
---|
49 | require({has:{"some-new-has-feature":7}}); |
---|
50 | t.is(has("some-new-has-feature"), 7); |
---|
51 | } |
---|
52 | ]); |
---|
53 | doh.runOnLoad(); |
---|
54 | }); |
---|
55 | </script> |
---|
56 | </head> |
---|
57 | <body> |
---|
58 | </body> |
---|
59 | </html> |
---|