UNPKG

can

Version:

MIT-licensed, client-side, JavaScript framework that makes building rich web applications easy.

63 lines (57 loc) 2.45 kB
<!DOCTYPE html> <html> <head> <title>parseOnLoad:true, async:false unit test</title> <style type="text/css"> @import "../../resources/dojo.css"; </style> <script type="text/javascript" src="../../dojo.js" data-dojo-config="isDebug:true, parseOnLoad: true"></script> <script type="text/javascript"> require(["doh", "dojo/ready"], function(doh, ready){ ready(function(){ doh.register("parseOnLoad declarative-require", function parseOnLoad(){ doh.is("object", typeof dr1, "dr1 created"); doh.is("bar", dr1.params.foo, "dr1 parameters set on instantiation"); doh.is("object", typeof dr2, "dr2 created"); doh.is("bar", dr2.params.foo, "dr2 parameters set on instantiation"); doh.is("object", typeof dr3, "dr3 created"); doh.is("bar", dr3.params.foo, "dr3 parameters set on instantiation"); doh.is(2, dr4.params.foo, "module loaded and executed"); doh.is(3, dr5.method1(1), "declarative script has access to parser scope"); }); doh.run(); }); }); </script> </head> <body> <h1>parseOnLoad:true, async:false unit test</h1> <p>This page tests that:</p> <ol> <li>parseOnLoad: true parses the page on load</li> <li>since async:true is NOT set, parseOnLoad:true works (with deprecation message) even if there's no explicit require() of dojo/parser</li> <li>the parse happens before the ready() callback happens, including processing of declarative requires</li> </ol> <p>See console for test results.</p> <script type="dojo/require"> AMDWidget: "dojo/tests/resources/AMDWidget", AMDWidget2: "dojo/tests/resources/AMDWidget2" </script> <div data-dojo-id="dr1" data-dojo-type="AMDWidget" data-dojo-props="foo: 'bar'"></div> <div data-dojo-id="dr2" data-dojo-type="AMDWidget2" data-dojo-props="foo: 'bar'"></div> <script type="dojo/require"> "acme.AMDWidget3": "dojo/tests/resources/AMDWidget3" </script> <div data-dojo-id="dr3" data-dojo-type="acme.AMDWidget3" data-dojo-props="foo: 'bar'"></div> <script type="dojo/require"> amdmodule: "dojo/tests/resources/amdmodule" </script> <div data-dojo-id="dr4" data-dojo-type="AMDWidget" data-dojo-props="foo: amdmodule(1)"></div> <div data-dojo-id="dr5" data-dojo-type="AMDWidget2"> <script type="dojo/aspect" data-dojo-advice="before" data-dojo-method="method1" data-dojo-args="value"> return [amdmodule(value)]; </script> </div> </body> </html>