Skip to content

Commit bae4af5

Browse files
committed
Allow for an xhtml config option that uses document.createElementNS if it is true.
1 parent 9995ffa commit bae4af5

4 files changed

Lines changed: 27 additions & 16 deletions

File tree

docs/api.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,8 @@ <h2>
574574

575575
<p id="config-priority"><strong>priority</strong>: An array of module/file names to load immediately, before tracing down any other dependencies. This allows you to set up a small set of files that are downloaded in parallel that contain most of the modules and their dependencies already built in. More information is in the <a href="faq-optimization#priority">Optimization FAQ, Priority Downloads</a>.<b>Note:</b> resources loaded by loader plugins (like 'text!template.html') <b>cannot</b> be specified in the priority array: the priority mechanism only works with regular JavaScript resources.</p>
576576

577+
<p id="config-xhtml"><strong>xhtml</strong>: If set to true, document.createElementNS() will be used to create script elements.</p>
578+
577579
<p id="config-urlArgs"><strong>urlArgs</strong>: Extra query string arguments appended to URLs that RequireJS uses to fetch resources. Most useful to cache bust when the browser or server is not configured correctly. Example cache bust setting for urlArgs:</p>
578580

579581
<pre><code>urlArgs: "bust=" + (new Date()).getTime()

order.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
req: req,
133133
onLoad: onLoad
134134
});
135-
require.attach(url, "", name, scriptCacheCallback, "script/cache");
135+
require.attach(url, null, name, scriptCacheCallback, "script/cache");
136136
}
137137
}
138138
}

require.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,8 +1499,8 @@ var require, define;
14991499
* @param {Object} url the URL to the module.
15001500
*/
15011501
req.load = function (context, moduleName, url) {
1502-
var contextName = context.contextName,
1503-
loaded = context.loaded;
1502+
var loaded = context.loaded;
1503+
15041504
isDone = false;
15051505

15061506
//Only set loaded to false for tracking if it has not already been set.
@@ -1509,7 +1509,7 @@ var require, define;
15091509
}
15101510

15111511
context.scriptCount += 1;
1512-
req.attach(url, contextName, moduleName);
1512+
req.attach(url, context, moduleName);
15131513

15141514
//If tracking a jQuery, then make sure its ready callbacks
15151515
//are put on hold to prevent its ready callbacks from
@@ -1669,17 +1669,19 @@ var require, define;
16691669
* environment. Right now only supports browser loading,
16701670
* but can be redefined in other environments to do the right thing.
16711671
* @param {String} url the url of the script to attach.
1672-
* @param {String} contextName the name of the context that wants the script.
1672+
* @param {Object} context the context that wants the script.
16731673
* @param {moduleName} the name of the module that is associated with the script.
16741674
* @param {Function} [callback] optional callback, defaults to require.onScriptLoad
16751675
* @param {String} [type] optional type, defaults to text/javascript
16761676
*/
1677-
req.attach = function (url, contextName, moduleName, callback, type) {
1678-
var node, loaded, context;
1677+
req.attach = function (url, context, moduleName, callback, type) {
1678+
var node, loaded;
16791679
if (isBrowser) {
16801680
//In the browser so use a script tag
16811681
callback = callback || req.onScriptLoad;
1682-
node = document.createElement("script");
1682+
node = context && context.config && context.config.xhtml ?
1683+
document.createElementNS("http://www.w3.org/1999/xhtml", "html:script") :
1684+
document.createElement("script");
16831685
node.type = type || "text/javascript";
16841686
node.charset = "utf-8";
16851687
//Use async so Gecko does not block on executing the script if something
@@ -1694,7 +1696,7 @@ var require, define;
16941696
//plugin
16951697
node.async = !s.skipAsync[url];
16961698

1697-
node.setAttribute("data-requirecontext", contextName);
1699+
node.setAttribute("data-requirecontext", context.contextName);
16981700
node.setAttribute("data-requiremodule", moduleName);
16991701

17001702
//Set up load listener. Test attachEvent first because IE9 has
@@ -1737,7 +1739,6 @@ var require, define;
17371739
//are in play, the expectation that a build has been done so that
17381740
//only one script needs to be loaded anyway. This may need to be
17391741
//reevaluated if other use cases become common.
1740-
context = contexts[contextName];
17411742
loaded = context.loaded;
17421743
loaded[moduleName] = false;
17431744

tasks.txt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ https://github.com/mozilla/chromeless/commit/cdc5e90ff2cb3316caa8e0c17533cc8d6c5
1919
https://github.com/mozilla/chromeless/blob/cdc5e90ff2cb3316caa8e0c17533cc8d6c5b3ea0/tests/requirejs/require.js.patch
2020

2121

22+
- anonymous define call 4th case:
23+
We found a fourth path, two calls to define() in one file.
24+
require-debug.js reports this error as:
25+
Second anonymous define(): <the text of the second function found>
26+
so then you can search for the text of the second function to perhaps understand the problem.
27+
28+
Docs:
29+
- http://requirejs.org/docs/api.html#jsfiles make the "plain script tag rules"
30+
more of a bulleted list to call them out.
31+
- Update api.html#define to indicate commonjs wrapper.
32+
- Interaction of node_modules and paths in r.js
33+
- Pointer to motivations behind current thing, reason for dependencies.
34+
35+
2236
- Update the coffeescript plugin to use the writeFile API?
2337

2438
- jjb's diagnostic/debug branch with dependency mappings
@@ -49,12 +63,6 @@ https://github.com/mozilla/chromeless/blob/cdc5e90ff2cb3316caa8e0c17533cc8d6c5b3
4963
selenium tests.
5064
- http://trac.dojotoolkit.org/ticket/13113
5165

52-
Docs:
53-
- http://requirejs.org/docs/api.html#jsfiles make the "plain script tag rules"
54-
more of a bulleted list to call them out.
55-
- Update api.html#define to indicate commonjs wrapper.
56-
- Pointer to motivations behind current thing, reason for dependencies.
57-
5866
- https://github.com/jrburke/requirejs/pull/71: process by 2/21
5967

6068

0 commit comments

Comments
 (0)