Permalink
Browse files

Remove the code that tries to upgrade run.js to use the latest versio…

…n in the page if more than one run.js is loaded. This is full of holes, and in reality better controlled via load order in the page/page authoring. Multiple versions of run can be included in the page, but only the first one defined will be active.
  • Loading branch information...
James Burke
James Burke committed Dec 21, 2009
1 parent c7c70bc commit 401f926026e97800d51980ed33c5c0ee4cd3cc4d
Showing with 10 additions and 35 deletions.
  1. +7 −24 run.js
  2. +3 −11 tasks.txt
View
31 run.js
@@ -14,28 +14,17 @@ setTimeout: false */
//Change this version number for each release.
var version = [0, 0, 5, ""],
run = typeof run === "undefined" ? null : run,
- oldRun, empty = {}, s,
+ empty = {}, s,
i, defContextName = "_", contextLoads = [],
scripts, script, rePkg, src, m,
readyRegExp = /complete|loaded/,
isBrowser = typeof window !== "undefined" && navigator && document,
ostring = Object.prototype.toString;
- //Check for an existing version of run.
- //Only overwrite if there is a version of run and it is less
- //than this version.
+ //Check for an existing version of run. If so, then exit out. Only allow
+ //one version of run to be active in a page.
if (run) {
- if (!run.version) {
- return;
- } else {
- for (i = 0; i < 2; i++) {
- if (run.version[i] >= version[i]) {
- return;
- }
- }
- }
- //Save off old state and reset state on old item to avoid bad callbacks.
- oldRun = run;
+ return;
}
function makeContextFunc(name, contextName) {
@@ -307,12 +296,8 @@ setTimeout: false */
run.global.run = run;
run.version = version;
- //Set up page state. If an existing run, prefer its state.
- s = run.s = (oldRun && oldRun.s) || {};
-
- //In case oldRun has missing state properties (like from a build) or
- //it is a really new empty state object, fill it out.
- run.mixin(s, {
+ //Set up page state.
+ s = run.s = {
ctxName: defContextName,
contexts: {},
plugins: {
@@ -324,15 +309,13 @@ setTimeout: false */
isPageLoaded: !isBrowser,
pageCallbacks: [],
doc: isBrowser ? document : null
- });
+ };
s.head = s.head || isBrowser ?
(s.doc.getElementsByTagName("head")[0] ||
s.doc.getElementsByTagName("html")[0]) : null;
run.isBrowser = s.isBrowser;
run.doc = s.doc;
- oldRun = null;
-
//Set up page load detection for the browser case.
if (run.isBrowser && !s.baseUrl) {
//Figure out baseUrl. Get it from the script tag with run.js in it.
View
@@ -1,19 +1,9 @@
-- The run plugin handling probably does not upgrade itself to use the latest version
- of run's plugins if two versions of run are on the page. Implement a version
- number for each plugin and check it.
- - Or just wipe the plugins, they should keep their state on the plugins.
- Only problem is the assumption that they need to get loaded? Maybe track
- loaded plugins and reload them, so the fact they are outstanding should old
- the logic to trace deps?
-
- Need a domcontentloaded for IE, use the scrollLeft trick?
- Move to github
- loading more than one locale for a page. A locales= option?
-- Profile a run.js impl that does not do type checks for the args. Does it make a noticeable difference?
-
- convertDojo.js: add in pause/resume when more than one provide is in the file.
- Caveat with .modify: you cannot modify the top-level function. We could remove
@@ -25,7 +15,9 @@ The issue being that for a circular dependency, the function method will actuall
be a proxy method. So that function will not be the same in that module vs
another module. This could be a problem if some module was given that
module and does an if (varFunc === doFunc) sort of test, but that seems like a
-rarity/less valuable than having function modules.
+rarity/less valuable than having function modules. Also could be a problem for
+objects too, but again, only an issue in circular dependency cases, and the good
+seems to outweigh the possibility of this edge case.
- Rhino tests.

0 comments on commit 401f926

Please sign in to comment.