mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
checkbox widget fix
This commit is contained in:
parent
e8ac57caae
commit
cd03fe92a5
4 changed files with 26 additions and 7 deletions
11
angular-debug.js
vendored
11
angular-debug.js
vendored
|
|
@ -3185,13 +3185,13 @@ function valueAccessor(scope, element) {
|
|||
}
|
||||
|
||||
function checkedAccessor(scope, element) {
|
||||
var domElement = element[0];
|
||||
var domElement = element[0], elementValue = domElement.value;
|
||||
return {
|
||||
get: function(){
|
||||
return !!domElement.checked;
|
||||
},
|
||||
set: function(value){
|
||||
domElement.checked = !!value;
|
||||
domElement.checked = toBoolean(value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -3444,8 +3444,13 @@ angularService("$location", function(browser){
|
|||
scope.$root.$eval();
|
||||
});
|
||||
parse(browser.getUrl());
|
||||
var lastURL;
|
||||
this.$onEval(PRIORITY_LAST, function(){
|
||||
browser.setUrl(toString());
|
||||
var url = toString();
|
||||
if (lastURL != url) {
|
||||
browser.setUrl(url);
|
||||
lastURL = url;
|
||||
}
|
||||
});
|
||||
return location;
|
||||
}, {inject: ['$browser']});
|
||||
|
|
|
|||
|
|
@ -44,8 +44,13 @@ angularService("$location", function(browser){
|
|||
scope.$root.$eval();
|
||||
});
|
||||
parse(browser.getUrl());
|
||||
var lastURL;
|
||||
this.$onEval(PRIORITY_LAST, function(){
|
||||
browser.setUrl(toString());
|
||||
var url = toString();
|
||||
if (lastURL != url) {
|
||||
browser.setUrl(url);
|
||||
lastURL = url;
|
||||
}
|
||||
});
|
||||
return location;
|
||||
}, {inject: ['$browser']});
|
||||
|
|
|
|||
|
|
@ -49,13 +49,13 @@ function valueAccessor(scope, element) {
|
|||
}
|
||||
|
||||
function checkedAccessor(scope, element) {
|
||||
var domElement = element[0];
|
||||
var domElement = element[0], elementValue = domElement.value;
|
||||
return {
|
||||
get: function(){
|
||||
return !!domElement.checked;
|
||||
},
|
||||
set: function(value){
|
||||
domElement.checked = !!value;
|
||||
domElement.checked = toBoolean(value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,9 +6,10 @@ describe("input widget", function(){
|
|||
scope = null;
|
||||
element = null;
|
||||
var compiler = new Compiler(angularTextMarkup, angularAttrMarkup, angularDirective, angularWidget);
|
||||
compile = function(html) {
|
||||
compile = function(html, before) {
|
||||
element = jqLite(html);
|
||||
scope = compiler.compile(element)(element);
|
||||
(before||noop)();
|
||||
scope.$init();
|
||||
};
|
||||
});
|
||||
|
|
@ -51,6 +52,14 @@ describe("input widget", function(){
|
|||
expect(scope.$get('list')).toEqual(['1', '2', '3']);
|
||||
});
|
||||
|
||||
it("should process ng-format for booleans", function(){
|
||||
compile('<input type="checkbox" name="name" value="true" ng-format="boolean"/>', function(){
|
||||
scope.name = false;
|
||||
});
|
||||
expect(scope.name).toEqual(false);
|
||||
expect(scope.$element[0].checked).toEqual(false);
|
||||
});
|
||||
|
||||
it("should process ng-validation", function(){
|
||||
compile('<input type="text" name="price" value="abc" ng-validate="number"/>');
|
||||
expect(element.hasClass('ng-validation-error')).toBeTruthy();
|
||||
|
|
|
|||
Loading…
Reference in a new issue