3.0 source code
This commit is contained in:
43
OfficeWeb/vendor/requirejs/tests/domReady/domReady-tests.js
vendored
Normal file
43
OfficeWeb/vendor/requirejs/tests/domReady/domReady-tests.js
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
/*jslint */
|
||||
/*global requirejs: false, doh: false, document: false */
|
||||
|
||||
requirejs.config({
|
||||
paths: {
|
||||
domReady: '../../../domReady/domReady'
|
||||
}
|
||||
});
|
||||
|
||||
//Event handlers can fire out of order, so way until both have fired before
|
||||
//doing the final test.
|
||||
var finishCounter = 0;
|
||||
function finished() {
|
||||
finishCounter += 1;
|
||||
if (finishCounter === 2) {
|
||||
doh.register(
|
||||
"domReady",
|
||||
[
|
||||
function domReady(t) {
|
||||
t.is('one', document.getElementById('one').getAttribute('data-name'));
|
||||
t.is('two', document.getElementById('two').getAttribute('data-name'));
|
||||
}
|
||||
]
|
||||
);
|
||||
doh.run();
|
||||
}
|
||||
}
|
||||
|
||||
requirejs(['domReady'], function (domReady) {
|
||||
requirejs(['one'], function (one) {
|
||||
domReady(function () {
|
||||
one.addToDom();
|
||||
finished();
|
||||
});
|
||||
});
|
||||
|
||||
requirejs(['two'], function (two) {
|
||||
domReady(function () {
|
||||
two.addToDom();
|
||||
finished();
|
||||
});
|
||||
});
|
||||
});
|
||||
14
OfficeWeb/vendor/requirejs/tests/domReady/domReady.html
vendored
Normal file
14
OfficeWeb/vendor/requirejs/tests/domReady/domReady.html
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>require.js: domReady Test</title>
|
||||
<script type="text/javascript" src="../doh/runner.js"></script>
|
||||
<script type="text/javascript" src="../doh/_browserRunner.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>require.js: domReady Test</h1>
|
||||
<p>Check console for messages</p>
|
||||
|
||||
<script type="text/javascript" data-main="domReady-tests" src="../../require.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
41
OfficeWeb/vendor/requirejs/tests/domReady/domReadyExtraConfig-tests.js
vendored
Normal file
41
OfficeWeb/vendor/requirejs/tests/domReady/domReadyExtraConfig-tests.js
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
/*jslint */
|
||||
/*global requirejs: false, doh: false, document: false */
|
||||
|
||||
requirejs.config({
|
||||
paths: {
|
||||
domReady: '../../../domReady/domReady'
|
||||
}
|
||||
});
|
||||
|
||||
//Event handlers can fire out of order, so way until both have fired before
|
||||
//doing the final test.
|
||||
var finishCounter = 0,
|
||||
master = new doh.Deferred();
|
||||
|
||||
function finished() {
|
||||
finishCounter += 1;
|
||||
if (finishCounter === 2) {
|
||||
master.callback(true);
|
||||
}
|
||||
}
|
||||
|
||||
doh.register(
|
||||
"domReadyExtraConfig",
|
||||
[
|
||||
{
|
||||
name: "domReadyExtraConfig",
|
||||
timeout: 3000,
|
||||
runTest: function () {
|
||||
return master;
|
||||
}
|
||||
}
|
||||
]
|
||||
);
|
||||
doh.run();
|
||||
|
||||
requirejs(['domReady'], finished);
|
||||
|
||||
require(['domReady!'], finished);
|
||||
|
||||
//This should not cause a problem, but did before #398 was fixed.
|
||||
require.config({ });
|
||||
17
OfficeWeb/vendor/requirejs/tests/domReady/domReadyExtraConfig.html
vendored
Normal file
17
OfficeWeb/vendor/requirejs/tests/domReady/domReadyExtraConfig.html
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>require.js: domReady Extra Config Test</title>
|
||||
<script type="text/javascript" src="../doh/runner.js"></script>
|
||||
<script type="text/javascript" src="../doh/_browserRunner.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>require.js: domReady Extra Config Test</h1>
|
||||
|
||||
<p><a href="https://github.com/jrburke/requirejs/issues/398">More info in #398</a></p>
|
||||
|
||||
<p>Check console for messages</p>
|
||||
|
||||
<script type="text/javascript" data-main="domReadyExtraConfig-tests" src="../../require.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
8
OfficeWeb/vendor/requirejs/tests/domReady/one.js
vendored
Normal file
8
OfficeWeb/vendor/requirejs/tests/domReady/one.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
define({
|
||||
addToDom: function () {
|
||||
var div = document.createElement('div');
|
||||
div.id = 'one';
|
||||
div.setAttribute('data-name', 'one');
|
||||
document.getElementsByTagName('body')[0].appendChild(div);
|
||||
}
|
||||
});
|
||||
8
OfficeWeb/vendor/requirejs/tests/domReady/two.js
vendored
Normal file
8
OfficeWeb/vendor/requirejs/tests/domReady/two.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
define({
|
||||
addToDom: function () {
|
||||
var div = document.createElement('div');
|
||||
div.id = 'two';
|
||||
div.setAttribute('data-name', 'two');
|
||||
document.getElementsByTagName('body')[0].appendChild(div);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user