From 4444290321dd7022dff80d25b2a3cfdcdfb697eb Mon Sep 17 00:00:00 2001 From: guybedford Date: Thu, 27 Mar 2014 11:55:50 -0700 Subject: [PATCH] ie8 global adjustment, lastIndexOf fix --- dist/system-amd-production.js | 6 ++---- dist/system-amd-production.min.js | 2 +- dist/system.js | 16 +++++++--------- dist/system.min.js | 2 +- lib/polyfill-wrapper-start.js | 4 +--- lib/system-amd-production.js | 2 +- lib/system-format-amd.js | 2 +- lib/system-formats.js | 4 ++-- lib/system-plugins.js | 6 +++--- test/tests/shim-map-test.js | 2 +- 10 files changed, 20 insertions(+), 26 deletions(-) diff --git a/dist/system-amd-production.js b/dist/system-amd-production.js index 2bb24009..c7260d4f 100644 --- a/dist/system-amd-production.js +++ b/dist/system-amd-production.js @@ -19,7 +19,7 @@ global.upgradeSystemLoader = function() { return -1; }; - var sLastIndexOf = String.prototype.lastIndexOf || function(c) { + var lastIndexOf = Array.prototype.lastIndexOf || function(c) { for (var i = this.length - 1; i >= 0; i--) { if (this[i] === c) { return i; @@ -27,8 +27,6 @@ global.upgradeSystemLoader = function() { } return -i; }; - - var aLastIndexOf = Array.prototype.lastIndexOf || sLastIndexOf; /* SystemJS Core Adds normalization to the import function, as well as __useDefault support @@ -266,7 +264,7 @@ global.upgradeSystemLoader = function() { })(factory); for (var i = 0; i < deps.length; i++) - if (aLastIndexOf.call(deps, deps[i]) != i) + if (lastIndexOf.call(deps, deps[i]) != i) deps.splice(i--, 1); var instantiate = { diff --git a/dist/system-amd-production.min.js b/dist/system-amd-production.min.js index f8925d42..e12c17f4 100644 --- a/dist/system-amd-production.min.js +++ b/dist/system-amd-production.min.js @@ -5,4 +5,4 @@ * MIT License */ -!function(e){e.upgradeSystemLoader=function(){e.upgradeSystemLoader=void 0;var t=Array.prototype.indexOf||function(e){for(var t=0,n=this.length;n>t;t++)if(this[t]===e)return t;return-1},n=String.prototype.lastIndexOf||function(e){for(var t=this.length-1;t>=0;t--)if(this[t]===e)return t;return-t},r=Array.prototype.lastIndexOf||n;!function(e){if("undefined"==typeof System)throw"System not defined. Include the `es6-module-loader.js` polyfill before SystemJS.";var t=System,n=function(e){if(!(e instanceof Module)){for(var t=[],r=0;rr.length)return 0;for(var s=0;sparseInt(a[i])?1:-1}return 0},r=System.normalize;System.versions=System.versions||{},System.normalize=function(s,a,i){var u=System.versions;return Promise.resolve(r.call(this,s,a,i)).then(function(r){var s,a,i,o,l=t.call(r,"@");if(-1==l){for(var m in u)if(o=u[m],r.substr(0,m.length)==m&&(i=r.charAt(m.length),!i||"/"==i))return m+"@"+("string"==typeof o?o:o[o.length-1])+r.substr(m.length);return r}s=r.substr(l+1).split("/")[0];var f,d=s.length;if("^"==s.substr(0,1)&&(s=s.substr(1),f=!0),a=s.match(e),!a)return r;f&&(a[2]||(f=!1),a[3]||(a[2]>0?a[3]="0":f=!1)),f&&(a[1]>0?(a[2]||(s=a[1]+".0.0"),a[3]||(s=a[1]+".0"),f=s,a=[a[1]]):a[2]>0?(f=s,a=[0,a[2]]):(f=!1,a=[0,0,a[3]]),s=a.join("."));var c=r.substr(0,l);if(o=u[c]||[],"string"==typeof o&&(o=[o]),!a[3]||f)for(var y=o.length-1;y>=0;y--){var p=o[y];if(p.substr(0,s.length)==s&&p.charAt(s.length).match(/^[\.\-]?$/)&&(!f||f&&-1!=n(p,f)))return c+"@"+p+r.substr(c.length+d+1)}return-1==t.call(o,s)&&(o.push(s),o.sort(n),r=c+"@"+s+r.substr(c.length+d+1),a[3]&&-1!=(l=t.call(o,a[1]+"."+a[2]))&&o.splice(l,1),a[2]&&-1!=(l=t.call(o,a[1]))&&o.splice(l,1),u[c]=1==o.length?o[0]:o),r})}}()},function(){if(!e.System||e.System.registerModule)if("undefined"!=typeof window){var t=document.getElementsByTagName("script"),n=t[t.length-1].src,r=n.substr(0,sLastIndexOf.call(n,"/")+1);document.write('')}else{var s=require("es6-module-loader");e.System=s.System,e.Loader=s.Loader,e.Module=s.Module,module.exports=e.System,e.upgradeSystemLoader()}else e.upgradeSystemLoader()}()}("undefined"!=typeof window?window:global); \ No newline at end of file +!function(e){e.upgradeSystemLoader=function(){e.upgradeSystemLoader=void 0;var t=Array.prototype.indexOf||function(e){for(var t=0,n=this.length;n>t;t++)if(this[t]===e)return t;return-1},n=Array.prototype.lastIndexOf||function(e){for(var t=this.length-1;t>=0;t--)if(this[t]===e)return t;return-t};!function(e){if("undefined"==typeof System)throw"System not defined. Include the `es6-module-loader.js` polyfill before SystemJS.";var t=System,n=function(e){if(!(e instanceof Module)){for(var t=[],r=0;rr.length)return 0;for(var s=0;sparseInt(a[i])?1:-1}return 0},r=System.normalize;System.versions=System.versions||{},System.normalize=function(s,a,i){var u=System.versions;return Promise.resolve(r.call(this,s,a,i)).then(function(r){var s,a,i,o,l=t.call(r,"@");if(-1==l){for(var m in u)if(o=u[m],r.substr(0,m.length)==m&&(i=r.charAt(m.length),!i||"/"==i))return m+"@"+("string"==typeof o?o:o[o.length-1])+r.substr(m.length);return r}s=r.substr(l+1).split("/")[0];var f,d=s.length;if("^"==s.substr(0,1)&&(s=s.substr(1),f=!0),a=s.match(e),!a)return r;f&&(a[2]||(f=!1),a[3]||(a[2]>0?a[3]="0":f=!1)),f&&(a[1]>0?(a[2]||(s=a[1]+".0.0"),a[3]||(s=a[1]+".0"),f=s,a=[a[1]]):a[2]>0?(f=s,a=[0,a[2]]):(f=!1,a=[0,0,a[3]]),s=a.join("."));var c=r.substr(0,l);if(o=u[c]||[],"string"==typeof o&&(o=[o]),!a[3]||f)for(var y=o.length-1;y>=0;y--){var p=o[y];if(p.substr(0,s.length)==s&&p.charAt(s.length).match(/^[\.\-]?$/)&&(!f||f&&-1!=n(p,f)))return c+"@"+p+r.substr(c.length+d+1)}return-1==t.call(o,s)&&(o.push(s),o.sort(n),r=c+"@"+s+r.substr(c.length+d+1),a[3]&&-1!=(l=t.call(o,a[1]+"."+a[2]))&&o.splice(l,1),a[2]&&-1!=(l=t.call(o,a[1]))&&o.splice(l,1),u[c]=1==o.length?o[0]:o),r})}}()},function(){if(!e.System||e.System.registerModule)if("undefined"!=typeof window){var t=document.getElementsByTagName("script"),n=t[t.length-1].src,r=n.substr(0,sLastIndexOf.call(n,"/")+1);document.write('')}else{var s=require("es6-module-loader");e.System=s.System,e.Loader=s.Loader,e.Module=s.Module,module.exports=e.System,e.upgradeSystemLoader()}else e.upgradeSystemLoader()}()}("undefined"!=typeof window?window:global); \ No newline at end of file diff --git a/dist/system.js b/dist/system.js index e9eb6942..7b386163 100644 --- a/dist/system.js +++ b/dist/system.js @@ -19,7 +19,7 @@ global.upgradeSystemLoader = function() { return -1; }; - var sLastIndexOf = String.prototype.lastIndexOf || function(c) { + var lastIndexOf = Array.prototype.lastIndexOf || function(c) { for (var i = this.length - 1; i >= 0; i--) { if (this[i] === c) { return i; @@ -27,8 +27,6 @@ global.upgradeSystemLoader = function() { } return -i; }; - - var aLastIndexOf = Array.prototype.lastIndexOf || sLastIndexOf; /* SystemJS Core Adds normalization to the import function, as well as __useDefault support @@ -136,7 +134,7 @@ global.upgradeSystemLoader = function() { var curScript = document.getElementsByTagName('script'); curScript = curScript[curScript.length - 1]; // set the path to traceur - var traceurSrc = curScript.getAttribute('data-traceur-src') || curScript.src.substr(0, sLastIndexOf.call(curScript.src, '/') + 1) + 'traceur.js'; + var traceurSrc = curScript.getAttribute('data-traceur-src') || curScript.src.substr(0, curScript.src.lastIndexOf('/') + 1) + 'traceur.js'; } // also in ESML, build.js @@ -214,7 +212,7 @@ global.upgradeSystemLoader = function() { // remove duplicates from deps first for (var i = 0; i < deps.length; i++) - if (aLastIndexOf.call(deps, deps[i]) != i) + if (lastIndexOf.call(deps, deps[i]) != i) deps.splice(i--, 1); return { @@ -278,7 +276,7 @@ global.upgradeSystemLoader = function() { function prepareDeps(deps, meta) { for (var i = 0; i < deps.length; i++) - if (aLastIndexOf.call(deps, deps[i]) != i) + if (lastIndexOf.call(deps, deps[i]) != i) deps.splice(i--, 1); // remove system dependencies @@ -761,12 +759,12 @@ global.upgradeSystemLoader = function() { return Promise.resolve(systemNormalize(name, parentName, parentAddress)) .then(function(name) { // if this is a plugin, normalize the plugin name and the argument - var pluginIndex = sLastIndexOf.call(name, '!'); + var pluginIndex = name.lastIndexOf('!'); if (pluginIndex != -1) { var argumentName = name.substr(0, pluginIndex); // plugin name is part after "!" or the extension itself - var pluginName = name.substr(pluginIndex + 1) || argumentName.substr(sLastIndexOf.call(argumentName, '.') + 1); + var pluginName = name.substr(pluginIndex + 1) || argumentName.substr(argumentName.lastIndexOf('.') + 1); // normalize the plugin name relative to the same parent return new Promise(function(resolve) { @@ -792,7 +790,7 @@ global.upgradeSystemLoader = function() { var name = load.name; // plugin - var pluginIndex = sLastIndexOf.call(name, '!'); + var pluginIndex = name.lastIndexOf('!'); if (pluginIndex != -1) { var pluginName = name.substr(pluginIndex + 1); diff --git a/dist/system.min.js b/dist/system.min.js index 8ea4a372..69d062b4 100644 --- a/dist/system.min.js +++ b/dist/system.min.js @@ -5,4 +5,4 @@ * MIT License */ -!function(e){e.upgradeSystemLoader=function(){e.upgradeSystemLoader=void 0;var t=Array.prototype.indexOf||function(e){for(var t=0,r=this.length;r>t;t++)if(this[t]===e)return t;return-1},r=String.prototype.lastIndexOf||function(e){for(var t=this.length-1;t>=0;t--)if(this[t]===e)return t;return-t},n=Array.prototype.lastIndexOf||r;!function(e){if("undefined"==typeof System)throw"System not defined. Include the `es6-module-loader.js` polyfill before SystemJS.";var t=System,r=function(e){if(!(e instanceof Module)){for(var t=[],n=0;nn.length)return 0;for(var s=0;sparseInt(a[o])?1:-1}return 0},n=System.normalize;System.versions=System.versions||{},System.normalize=function(s,a,o){var u=System.versions;return Promise.resolve(n.call(this,s,a,o)).then(function(n){var s,a,o,i,l=t.call(n,"@");if(-1==l){for(var m in u)if(i=u[m],n.substr(0,m.length)==m&&(o=n.charAt(m.length),!o||"/"==o))return m+"@"+("string"==typeof i?i:i[i.length-1])+n.substr(m.length);return n}s=n.substr(l+1).split("/")[0];var c,f=s.length;if("^"==s.substr(0,1)&&(s=s.substr(1),c=!0),a=s.match(e),!a)return n;c&&(a[2]||(c=!1),a[3]||(a[2]>0?a[3]="0":c=!1)),c&&(a[1]>0?(a[2]||(s=a[1]+".0.0"),a[3]||(s=a[1]+".0"),c=s,a=[a[1]]):a[2]>0?(c=s,a=[0,a[2]]):(c=!1,a=[0,0,a[3]]),s=a.join("."));var d=n.substr(0,l);if(i=u[d]||[],"string"==typeof i&&(i=[i]),!a[3]||c)for(var p=i.length-1;p>=0;p--){var y=i[p];if(y.substr(0,s.length)==s&&y.charAt(s.length).match(/^[\.\-]?$/)&&(!c||c&&-1!=r(y,c)))return d+"@"+y+n.substr(d.length+f+1)}return-1==t.call(i,s)&&(i.push(s),i.sort(r),n=d+"@"+s+n.substr(d.length+f+1),a[3]&&-1!=(l=t.call(i,a[1]+"."+a[2]))&&i.splice(l,1),a[2]&&-1!=(l=t.call(i,a[1]))&&i.splice(l,1),u[d]=1==i.length?i[0]:i),n})}}()},function(){if(!e.System||e.System.registerModule)if("undefined"!=typeof window){var t=document.getElementsByTagName("script"),r=t[t.length-1].src,n=r.substr(0,sLastIndexOf.call(r,"/")+1);document.write('')}else{var s=require("es6-module-loader");e.System=s.System,e.Loader=s.Loader,e.Module=s.Module,module.exports=e.System,e.upgradeSystemLoader()}else e.upgradeSystemLoader()}()}("undefined"!=typeof window?window:global); \ No newline at end of file +!function(e){e.upgradeSystemLoader=function(){e.upgradeSystemLoader=void 0;var t=Array.prototype.indexOf||function(e){for(var t=0,r=this.length;r>t;t++)if(this[t]===e)return t;return-1},r=Array.prototype.lastIndexOf||function(e){for(var t=this.length-1;t>=0;t--)if(this[t]===e)return t;return-t};!function(e){if("undefined"==typeof System)throw"System not defined. Include the `es6-module-loader.js` polyfill before SystemJS.";var t=System,r=function(e){if(!(e instanceof Module)){for(var t=[],n=0;nn.length)return 0;for(var s=0;sparseInt(a[o])?1:-1}return 0},n=System.normalize;System.versions=System.versions||{},System.normalize=function(s,a,o){var u=System.versions;return Promise.resolve(n.call(this,s,a,o)).then(function(n){var s,a,o,i,l=t.call(n,"@");if(-1==l){for(var m in u)if(i=u[m],n.substr(0,m.length)==m&&(o=n.charAt(m.length),!o||"/"==o))return m+"@"+("string"==typeof i?i:i[i.length-1])+n.substr(m.length);return n}s=n.substr(l+1).split("/")[0];var c,f=s.length;if("^"==s.substr(0,1)&&(s=s.substr(1),c=!0),a=s.match(e),!a)return n;c&&(a[2]||(c=!1),a[3]||(a[2]>0?a[3]="0":c=!1)),c&&(a[1]>0?(a[2]||(s=a[1]+".0.0"),a[3]||(s=a[1]+".0"),c=s,a=[a[1]]):a[2]>0?(c=s,a=[0,a[2]]):(c=!1,a=[0,0,a[3]]),s=a.join("."));var d=n.substr(0,l);if(i=u[d]||[],"string"==typeof i&&(i=[i]),!a[3]||c)for(var p=i.length-1;p>=0;p--){var y=i[p];if(y.substr(0,s.length)==s&&y.charAt(s.length).match(/^[\.\-]?$/)&&(!c||c&&-1!=r(y,c)))return d+"@"+y+n.substr(d.length+f+1)}return-1==t.call(i,s)&&(i.push(s),i.sort(r),n=d+"@"+s+n.substr(d.length+f+1),a[3]&&-1!=(l=t.call(i,a[1]+"."+a[2]))&&i.splice(l,1),a[2]&&-1!=(l=t.call(i,a[1]))&&i.splice(l,1),u[d]=1==i.length?i[0]:i),n})}}()},function(){if(!e.System||e.System.registerModule)if("undefined"!=typeof window){var t=document.getElementsByTagName("script"),r=t[t.length-1].src,n=r.substr(0,sLastIndexOf.call(r,"/")+1);document.write('')}else{var s=require("es6-module-loader");e.System=s.System,e.Loader=s.Loader,e.Module=s.Module,module.exports=e.System,e.upgradeSystemLoader()}else e.upgradeSystemLoader()}()}("undefined"!=typeof window?window:global); \ No newline at end of file diff --git a/lib/polyfill-wrapper-start.js b/lib/polyfill-wrapper-start.js index 7d7b53e8..f47e1cbf 100644 --- a/lib/polyfill-wrapper-start.js +++ b/lib/polyfill-wrapper-start.js @@ -12,7 +12,7 @@ global.upgradeSystemLoader = function() { return -1; }; - var sLastIndexOf = String.prototype.lastIndexOf || function(c) { + var lastIndexOf = Array.prototype.lastIndexOf || function(c) { for (var i = this.length - 1; i >= 0; i--) { if (this[i] === c) { return i; @@ -20,5 +20,3 @@ global.upgradeSystemLoader = function() { } return -i; }; - - var aLastIndexOf = Array.prototype.lastIndexOf || sLastIndexOf; diff --git a/lib/system-amd-production.js b/lib/system-amd-production.js index d6ccff39..d6c548e1 100644 --- a/lib/system-amd-production.js +++ b/lib/system-amd-production.js @@ -45,7 +45,7 @@ })(factory); for (var i = 0; i < deps.length; i++) - if (aLastIndexOf.call(deps, deps[i]) != i) + if (lastIndexOf.call(deps, deps[i]) != i) deps.splice(i--, 1); var instantiate = { diff --git a/lib/system-format-amd.js b/lib/system-format-amd.js index c2ddfec5..bd448aeb 100644 --- a/lib/system-format-amd.js +++ b/lib/system-format-amd.js @@ -45,7 +45,7 @@ function prepareDeps(deps, meta) { for (var i = 0; i < deps.length; i++) - if (aLastIndexOf.call(deps, deps[i]) != i) + if (lastIndexOf.call(deps, deps[i]) != i) deps.splice(i--, 1); // remove system dependencies diff --git a/lib/system-formats.js b/lib/system-formats.js index ddfadc18..57533c3b 100644 --- a/lib/system-formats.js +++ b/lib/system-formats.js @@ -29,7 +29,7 @@ var curScript = document.getElementsByTagName('script'); curScript = curScript[curScript.length - 1]; // set the path to traceur - var traceurSrc = curScript.getAttribute('data-traceur-src') || curScript.src.substr(0, sLastIndexOf.call(curScript.src, '/') + 1) + 'traceur.js'; + var traceurSrc = curScript.getAttribute('data-traceur-src') || curScript.src.substr(0, curScript.src.lastIndexOf('/') + 1) + 'traceur.js'; } // also in ESML, build.js @@ -107,7 +107,7 @@ // remove duplicates from deps first for (var i = 0; i < deps.length; i++) - if (aLastIndexOf.call(deps, deps[i]) != i) + if (lastIndexOf.call(deps, deps[i]) != i) deps.splice(i--, 1); return { diff --git a/lib/system-plugins.js b/lib/system-plugins.js index 2110edf9..60559fe1 100644 --- a/lib/system-plugins.js +++ b/lib/system-plugins.js @@ -17,12 +17,12 @@ return Promise.resolve(systemNormalize(name, parentName, parentAddress)) .then(function(name) { // if this is a plugin, normalize the plugin name and the argument - var pluginIndex = sLastIndexOf.call(name, '!'); + var pluginIndex = name.lastIndexOf('!'); if (pluginIndex != -1) { var argumentName = name.substr(0, pluginIndex); // plugin name is part after "!" or the extension itself - var pluginName = name.substr(pluginIndex + 1) || argumentName.substr(sLastIndexOf.call(argumentName, '.') + 1); + var pluginName = name.substr(pluginIndex + 1) || argumentName.substr(argumentName.lastIndexOf('.') + 1); // normalize the plugin name relative to the same parent return new Promise(function(resolve) { @@ -48,7 +48,7 @@ var name = load.name; // plugin - var pluginIndex = sLastIndexOf.call(name, '!'); + var pluginIndex = name.lastIndexOf('!'); if (pluginIndex != -1) { var pluginName = name.substr(pluginIndex + 1); diff --git a/test/tests/shim-map-test.js b/test/tests/shim-map-test.js index 58922056..31ee6b32 100644 --- a/test/tests/shim-map-test.js +++ b/test/tests/shim-map-test.js @@ -1 +1 @@ -shimdep = shimmapdep; \ No newline at end of file +window.shimdep = shimmapdep; \ No newline at end of file