Skip to content

Commit d718e10

Browse files
committed
Merge branch 'dev2.0' into patharray-257
2 parents fa453a5 + 7ddc7c3 commit d718e10

11 files changed

Lines changed: 316 additions & 2289 deletions

require.js

Lines changed: 196 additions & 171 deletions
Large diffs are not rendered by default.

require.old.js

Lines changed: 0 additions & 2085 deletions
This file was deleted.

tasks.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ DOC updates:
6060
- text plugin: make sure to use module.config() and update doc on how to set useXhr
6161
- i18n plugin: make sure to use module.config() and update doc on how to set
6262
locale, config listing on api.html
63+
- enforceDefine: true,
64+
- mention in error handling
65+
- create errors.html section for nodefine
66+
- ie9 cannot use error event listener because onreadystatechange fires first,
67+
and cannot use addEventListener (which has load fire after error) because
68+
of IE not firing onload right after script execution.
69+
- mention how it works with shim.exports string values.
70+
- #scripterror document on errors page.
6371

6472
Almond updates:
6573
- Support module.config.

tests/all.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ doh.registerUrl("pathArray", "../pathArray/pathArray.html", 8000);
116116
doh.registerUrl("pathArrayFail", "../pathArray/pathArrayFail.html", 8000);
117117

118118
doh.registerUrl("undef", "../undef/undef.html", 8000);
119+
doh.registerUrl("undefEnforceShim", "../undef/undefEnforceShim.html", 8000);
119120
doh.registerUrl("undefLocal", "../undef/undefLocal.html", 8000);
120121
doh.registerUrl("errorContinue", "../error/errorContinue.html", 8000);
121122
doh.registerUrl("errorContinueLocal", "../error/errorContinueLocal.html", 8000);

tests/cjsSpace/cjsSpace-tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require({
2-
baseUrl: './',
2+
baseUrl: './'
33
},
44
['a'],
55
function(a) {

tests/error/errorContinue.html

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@
1313
}
1414

1515
requirejs.onError = function (err) {
16-
17-
if (err.requireType === 'timeout') {
18-
var id = err.requireModules[0],
19-
config = {paths: {}};
20-
16+
if (err.requireModules) {
2117
setTimeout(function () {
2218
requirejs(['c', 'd'], function (c, d) {
2319
doh.is('c', c.name);
@@ -35,7 +31,8 @@
3531
};
3632

3733
requirejs({
38-
waitSeconds: 2
34+
waitSeconds: 2,
35+
enforceDefine: true
3936
}, ['a', 'b', 'broken'], function (a, b, broken) {
4037
doh.is("not-a", a.name);
4138
done();

tests/error/errorContinueLocal.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
}
1414

1515
requirejs({
16-
waitSeconds: 2
16+
waitSeconds: 2,
17+
enforceDefine: true
1718
}, ['a', 'b', 'broken'], function (a, b, broken) {
1819
doh.is("not-a", a.name);
1920
done();
2021
}, function (err) {
21-
if (err.requireType === 'timeout') {
22+
if (err.requireModules) {
2223
var id = err.requireModules[0],
2324
config = {paths: {}};
2425

tests/undef/globalFoo.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
var globalFoo = {
2+
name: 'globalFoo'
3+
};
4+

tests/undef/undef.html

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,26 @@
1818
}
1919

2020
requirejs.onError = function (err) {
21-
if (err.requireType === 'timeout') {
22-
var id = err.requireModules[0],
23-
config = {paths: {}};
21+
var id = err.requireModules[0],
22+
config = {paths: {}};
2423

25-
requirejs.undef(id);
26-
config.paths[id] = 'real';
24+
requirejs.undef(id);
25+
config.paths[id] = 'real';
2726

28-
requirejs.config(config);
27+
requirejs.config(config);
2928

30-
requirejs(['dep'], function (dep) {
31-
doh.is("real", dep.name);
32-
done();
33-
});
34-
return;
35-
}
29+
requirejs(['dep'], function (dep) {
30+
doh.is("real", dep.name);
31+
done();
32+
});
33+
return;
3634

3735
throw err;
3836
};
3937

4038
requirejs({
41-
waitSeconds: 2
39+
waitSeconds: 2,
40+
enforceDefine: true
4241
}, ['dep'], function (dep) {
4342
doh.is("real", dep.name);
4443
done();

tests/undef/undefEnforceShim.html

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>require.js: requirejs.undef() Test</title>
5+
<script type="text/javascript" src="../../require.js"></script>
6+
<script type="text/javascript" src="../doh/runner.js"></script>
7+
<script type="text/javascript" src="../doh/_browserRunner.js"></script>
8+
<script type="text/javascript">
9+
var doneCount = 0;
10+
var master = new doh.Deferred();
11+
function done() {
12+
doneCount += 1;
13+
//alert("done");
14+
if (doneCount == 2) {
15+
//alert("master callback");
16+
master.callback(true);
17+
}
18+
}
19+
20+
requirejs.onError = function (err) {
21+
var id = err.requireModules[0],
22+
config = {paths: {}};
23+
24+
if (id !== 'dep') {
25+
throw new Error('onError was expecting "dep" but got: ' + id);
26+
}
27+
28+
requirejs.undef(id);
29+
config.paths[id] = 'real';
30+
31+
requirejs.config(config);
32+
33+
requirejs(['dep'], function (dep) {
34+
35+
doh.is("real", dep.name);
36+
done();
37+
});
38+
return;
39+
40+
throw err;
41+
};
42+
43+
requirejs({
44+
waitSeconds: 2,
45+
enforceDefine: true,
46+
shim: {
47+
'globalFoo': {
48+
exports: 'globalFoo'
49+
}
50+
}
51+
}, ['globalFoo', 'dep'], function (globalFoo, dep) {
52+
doh.is("globalFoo", globalFoo.name);
53+
doh.is("real", dep.name);
54+
done();
55+
});
56+
57+
doh.register(
58+
"undef",
59+
[
60+
{
61+
name: "undef",
62+
timeout: 5000,
63+
runTest: function () {
64+
return master;
65+
}
66+
}
67+
]
68+
);
69+
doh.run();
70+
</script>
71+
</head>
72+
<body>
73+
<h1>require.js: requirejs.undef() Test</h1>
74+
<p>Use requirejs.undef() to reset and load a module from a different path.</p>
75+
<p>Check console for messages</p>
76+
</body>
77+
</html>

0 commit comments

Comments
 (0)