aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Angular.js2
-rw-r--r--test/AngularSpec.js36
2 files changed, 34 insertions, 4 deletions
diff --git a/src/Angular.js b/src/Angular.js
index b5dc7e5e..6c6ee1e4 100644
--- a/src/Angular.js
+++ b/src/Angular.js
@@ -1002,7 +1002,7 @@ function angularJsConfig(document, config) {
eachAttribute(jqLite(scripts[j]), function(value, name){
if (/^ng:/.exec(name)) {
name = name.substring(3).replace(/-/g, '_');
- if (name == 'autobind') value = true;
+ value = value || true;
config[name] = value;
}
});
diff --git a/test/AngularSpec.js b/test/AngularSpec.js
index 2352cdf8..e9215bee 100644
--- a/test/AngularSpec.js
+++ b/test/AngularSpec.js
@@ -266,25 +266,41 @@ describe('angular', function(){
});
- it('should extract angular config from the ng: attributes', function() {
+ it('should extract angular config from the ng: attributes',
+ function() {
var doc = { getElementsByTagName: function(tagName) {
expect(lowercase(tagName)).toEqual('script');
return [{nodeName: 'SCRIPT',
src: 'angularjs/angular.js',
- attributes: [{name: 'ng:autobind', value:undefined},
+ attributes: [{name: 'ng:autobind', value:'elementIdToCompile'},
{name: 'ng:css', value: 'css/my_custom_angular.css'},
{name: 'ng:ie-compat', value: 'myjs/angular-ie-compat.js'},
{name: 'ng:ie-compat-id', value: 'ngcompat'}] }];
}};
expect(angularJsConfig(doc)).toEqual({base_url: 'angularjs/',
- autobind: true,
+ autobind: 'elementIdToCompile',
css: 'css/my_custom_angular.css',
ie_compat: 'myjs/angular-ie-compat.js',
ie_compat_id: 'ngcompat'});
});
+ it('should extract angular config and default autobind value to true if present', function() {
+ var doc = { getElementsByTagName: function(tagName) {
+ expect(lowercase(tagName)).toEqual('script');
+ return [{nodeName: 'SCRIPT',
+ src: 'angularjs/angular.js',
+ attributes: [{name: 'ng:autobind', value:undefined}]}];
+ }};
+
+ expect(angularJsConfig(doc)).toEqual({autobind: true,
+ base_url: 'angularjs/',
+ ie_compat_id: 'ng-ie-compat',
+ ie_compat: 'angularjs/angular-ie-compat.js'});
+ });
+
+
it('should extract angular autobind config from the script hashpath attributes', function() {
var doc = { getElementsByTagName: function(tagName) {
expect(lowercase(tagName)).toEqual('script');
@@ -299,6 +315,20 @@ describe('angular', function(){
});
+ it('should extract autobind config with element id from the script hashpath', function() {
+ var doc = { getElementsByTagName: function(tagName) {
+ expect(lowercase(tagName)).toEqual('script');
+ return [{nodeName: 'SCRIPT',
+ src: 'angularjs/angular.js#autobind=foo'}];
+ }};
+
+ expect(angularJsConfig(doc)).toEqual({base_url: 'angularjs/',
+ autobind: 'foo',
+ ie_compat: 'angularjs/angular-ie-compat.js',
+ ie_compat_id: 'ng-ie-compat'});
+ });
+
+
it("should default to versioned ie-compat file if angular file is versioned", function() {
var doc = { getElementsByTagName: function(tagName) {
expect(lowercase(tagName)).toEqual('script');