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