web-apps/vendor/requirejs/tests/undef/undef.html

67 lines
1.7 KiB
HTML
Raw Normal View History

2016-03-11 00:48:53 +00:00
<!DOCTYPE html>
<html>
<head>
<title>require.js: requirejs.undef() Test</title>
<script type="text/javascript" src="../../require.js"></script>
<script type="text/javascript" src="../doh/runner.js"></script>
<script type="text/javascript" src="../doh/_browserRunner.js"></script>
<script type="text/javascript">
var doneCount = 0;
var master = new doh.Deferred();
function done() {
doneCount += 1;
//alert("done");
if (doneCount == 2) {
//alert("master callback");
master.callback(true);
}
}
requirejs.onError = function (err) {
var id = err.requireModules[0],
config = {paths: {}};
requirejs.undef(id);
config.paths[id] = 'real';
requirejs.config(config);
requirejs(['dep'], function (dep) {
doh.is("real", dep.name);
done();
});
return;
throw err;
};
requirejs({
waitSeconds: 2,
enforceDefine: true
}, ['dep'], function (dep) {
doh.is("real", dep.name);
done();
});
doh.register(
"undef",
[
{
name: "undef",
timeout: 5000,
runTest: function () {
return master;
}
}
]
);
doh.run();
</script>
</head>
<body>
<h1>require.js: requirejs.undef() Test</h1>
<p>Use requirejs.undef() to reset and load a module from a different path.</p>
<p>Check console for messages</p>
</body>
</html>