UNPKG

can

Version:

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

70 lines (67 loc) 2.26 kB
<!DOCTYPE html> <html> <head> <title>require.js: urlFetch Mapping Test</title> <script type="text/javascript"> var dohArgs = {async:0}; requirejsArgs= { dojoLocation:"../../../../.." }; </script> <script type="text/javascript" src="../requirejs-setup.js"></script> <script type="text/javascript" src="../../../../../dojo.js"></script> <script type="text/javascript"> require({ baseUrl: "./", paths: { 'one' : 'two', 'two' : 'two', 'three': 'three', 'four': 'three' } }, ["require", "one", "two", "three", "four", "doh"], function(require, one, two, three, four, doh) { doh.register( "urlfetch", [ function urlfetch(t){ //First confirm there is only one script tag for each //module: var scripts = document.getElementsByTagName("script"), i, counts = {}, url, props, something; for (var i = scripts.length - 1; i > -1; i--) { url = scripts[i].src; if (url) { if (!(url in counts)) { counts[url] = 0; } counts[url] += 1; } } if(require.async){ for (prop in counts) { t.is(1, counts[prop]); } } t.is("one", one.name); t.is("one", two.oneName); t.is("two", two.name); t.is("three", three.name); t.is("three", four.threeName); t.is("four", four.name); } ] ); doh.run(); } ); </script> </head> <body> <h1>require.js: urlFetch Mapping Test</h1> <p>Make sure that multiple modules mapped to the same URL only get the URL fetched once.</p> <p>Check console for messages</p> </body> </html>