mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-24 03:55:49 +08:00
refactor(ngBindAttr): remove
Breaks ng-bind-attr directive removed
This commit is contained in:
@@ -49,20 +49,6 @@ describe('Binder', function() {
|
||||
expect(element.text()).toBe('123');
|
||||
}));
|
||||
|
||||
it('AttributesNoneBound', inject(function($rootScope, $compile) {
|
||||
var a = $compile('<a href="abc" foo="def"></a>')($rootScope);
|
||||
expect(a[0].nodeName).toBe('A');
|
||||
expect(a.attr('ng-bind-attr')).toBeFalsy();
|
||||
}));
|
||||
|
||||
it('AttributesAreEvaluated', inject(function($rootScope, $compile) {
|
||||
var a = $compile('<a ng-bind-attr=\'{"a":"a", "b":"a+b={{a+b}}"}\'></a>')($rootScope);
|
||||
$rootScope.$eval('a=1;b=2');
|
||||
$rootScope.$apply();
|
||||
expect(a.attr('a')).toBe('a');
|
||||
expect(a.attr('b')).toBe('a+b=3');
|
||||
}));
|
||||
|
||||
it('InputTypeButtonActionExecutesInScope', inject(function($rootScope, $compile) {
|
||||
var savedCalled = false;
|
||||
element = $compile(
|
||||
@@ -414,29 +400,6 @@ describe('Binder', function() {
|
||||
expect(optionC.text()).toEqual('C');
|
||||
}));
|
||||
|
||||
it('DeleteAttributeIfEvaluatesFalse', inject(function($rootScope, $compile) {
|
||||
element = $compile(
|
||||
'<div>' +
|
||||
'<input ng-model="a0" ng-bind-attr="{disabled:\'{{true}}\'}">' +
|
||||
'<input ng-model="a1" ng-bind-attr="{disabled:\'{{false}}\'}">' +
|
||||
'<input ng-model="b0" ng-bind-attr="{disabled:\'{{1}}\'}">' +
|
||||
'<input ng-model="b1" ng-bind-attr="{disabled:\'{{0}}\'}">' +
|
||||
'<input ng-model="c0" ng-bind-attr="{disabled:\'{{[0]}}\'}">' +
|
||||
'<input ng-model="c1" ng-bind-attr="{disabled:\'{{[]}}\'}">' +
|
||||
'</div>')($rootScope);
|
||||
$rootScope.$apply();
|
||||
function assertChild(index, disabled) {
|
||||
expect(!!childNode(element, index).attr('disabled')).toBe(disabled);
|
||||
}
|
||||
|
||||
assertChild(0, true);
|
||||
assertChild(1, false);
|
||||
assertChild(2, true);
|
||||
assertChild(3, false);
|
||||
assertChild(4, true);
|
||||
assertChild(5, false);
|
||||
}));
|
||||
|
||||
it('ItShouldSelectTheCorrectRadioBox', inject(function($rootScope, $compile) {
|
||||
element = $compile(
|
||||
'<div>' +
|
||||
|
||||
@@ -77,37 +77,4 @@ describe('ng-bind-*', function() {
|
||||
expect(fromJson(element.text())).toEqual({key:'value'});
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
describe('ng-bind-attr', function() {
|
||||
it('should bind attributes', inject(function($rootScope, $compile) {
|
||||
element = $compile('<div ng-bind-attr="{src:\'http://localhost/mysrc\', alt:\'myalt\'}"/>')($rootScope);
|
||||
$rootScope.$digest();
|
||||
expect(element.attr('src')).toEqual('http://localhost/mysrc');
|
||||
expect(element.attr('alt')).toEqual('myalt');
|
||||
}));
|
||||
|
||||
it('should not pretty print JSON in attributes', inject(function($rootScope, $compile) {
|
||||
element = $compile('<img alt="{{ {a:1} }}"/>')($rootScope);
|
||||
$rootScope.$digest();
|
||||
expect(element.attr('alt')).toEqual('{"a":1}');
|
||||
}));
|
||||
|
||||
it('should remove special attributes on false', inject(function($rootScope, $compile) {
|
||||
element = $compile('<input ng-bind-attr="{disabled:\'{{disabled}}\', readonly:\'{{readonly}}\', checked:\'{{checked}}\'}"/>')($rootScope);
|
||||
var input = element[0];
|
||||
expect(input.disabled).toEqual(false);
|
||||
expect(input.readOnly).toEqual(false);
|
||||
expect(input.checked).toEqual(false);
|
||||
|
||||
$rootScope.disabled = true;
|
||||
$rootScope.readonly = true;
|
||||
$rootScope.checked = true;
|
||||
$rootScope.$digest();
|
||||
|
||||
expect(input.disabled).toEqual(true);
|
||||
expect(input.readOnly).toEqual(true);
|
||||
expect(input.checked).toEqual(true);
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user