diff options
| author | Igor Minar | 2010-10-19 21:53:16 -0700 |
|---|---|---|
| committer | Igor Minar | 2010-10-20 14:48:35 -0700 |
| commit | 6f3a757a37cf26f358220c52ff7db2ae56f31642 (patch) | |
| tree | fd255a13ec6ff9ecd82f7010c3d275a28132a14b | |
| parent | 2e687ee56fb81e96c0f45b2655a1a723331e2d20 (diff) | |
| download | angular.js-6f3a757a37cf26f358220c52ff7db2ae56f31642.tar.bz2 | |
Angular should look for angular-ie-compat file at the right location
The location should be based on the base path of the angular script
and the version identifier of the angular script.
ex: angular.js -> angular-ie-compat.js
js/angular-0.9.0.min.js -> js/angular-ie-compat-0.9.0.js
| -rw-r--r-- | src/Angular.js | 5 | ||||
| -rw-r--r-- | test/AngularSpec.js | 26 |
2 files changed, 28 insertions, 3 deletions
diff --git a/src/Angular.js b/src/Angular.js index 97ca7663..e17c143e 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -49,7 +49,7 @@ var _undefined = undefined, angularService = extensionMap(angular, 'service'), angularCallbacks = extensionMap(angular, 'callbacks'), nodeName, - rngScript = /^(|.*\/)angular(-.*)?(\.min)?.js(\?[^#]*)?(#(.*))?$/; + rngScript = /^(|.*\/)angular(-.*?)?(\.min)?.js(\?[^#]*)?(#(.*))?$/; function foreach(obj, iterator, context) { var key; @@ -426,14 +426,13 @@ function angularJsConfig(document, config) { var scripts = document.getElementsByTagName("script"), match; config = extend({ - base_url: '', - ie_compat: 'angular-ie-compat.js', ie_compat_id: 'ng-ie-compat' }, config); for(var j = 0; j < scripts.length; j++) { match = (scripts[j].src || "").match(rngScript); if (match) { config.base_url = match[1]; + config.ie_compat = match[1] + 'angular-ie-compat' + (match[2] || '') + '.js'; extend(config, parseKeyValue(match[6])); eachAttribute(jqLite(scripts[j]), function(value, name){ if (/^ng:/.exec(name)) { diff --git a/test/AngularSpec.js b/test/AngularSpec.js index daa0e13f..8c7249d9 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -223,4 +223,30 @@ describe('angularJsConfig', function() { ie_compat: 'myjs/angular-ie-compat.js', ie_compat_id: 'ngcompat'}); }); + + + it("should default to versioned ie-compat file if angular file is versioned", function() { + var doc = { getElementsByTagName: function(tagName) { + expect(lowercase(tagName)).toEqual('script'); + return [{nodeName: 'SCRIPT', + src: 'js/angular-0.9.0.js'}]; + }}; + + expect(angularJsConfig(doc)).toEqual({base_url: 'js/', + ie_compat: 'js/angular-ie-compat-0.9.0.js', + ie_compat_id: 'ng-ie-compat'}); + }); + + + it("should default to versioned ie-compat file if angular file is versioned and minified", function() { + var doc = { getElementsByTagName: function(tagName) { + expect(lowercase(tagName)).toEqual('script'); + return [{nodeName: 'SCRIPT', + src: 'js/angular-0.9.0-cba23f00.min.js'}]; + }}; + + expect(angularJsConfig(doc)).toEqual({base_url: 'js/', + ie_compat: 'js/angular-ie-compat-0.9.0-cba23f00.js', + ie_compat_id: 'ng-ie-compat'}); + }); }); |
