mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
angularJsConfig now allows ng:autobind and #autobind value to be passed in
This commit is contained in:
parent
5432dd289a
commit
7414e7b533
2 changed files with 34 additions and 4 deletions
|
|
@ -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;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Reference in a new issue