aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--angular-minified.js4
-rw-r--r--angular.js7
-rw-r--r--example/memoryLeak.html22
-rw-r--r--src/Validators.js7
-rw-r--r--test/ValidatorsTest.js2
5 files changed, 34 insertions, 8 deletions
diff --git a/angular-minified.js b/angular-minified.js
index 5cb82b29..c4982b82 100644
--- a/angular-minified.js
+++ b/angular-minified.js
@@ -82,8 +82,8 @@ u.U[a];if(!c){var d=new D(a);c=d.qa();d.L();u.U[a]=c}b=b||{};b.scope=this;return
k:b})},rb:function(){for(var a=this.q.$invalidWidgets;a.length>0;)a.pop()},Sb:function(a){this.q.$invalidWidgets.push(a)},watch:function(a){var b=this;(new D(a)).watch()({scope:this,jb:function(c,d){b.kb(c,function(e,f){try{return d({scope:b},e,f)}catch(g){alert(g)}})}})},kb:function(a,b){var c=this.ra[a];if(!c){c={Fa:[],s:a};this.ra[a]=c}c.Fa.push(b)},Gb:function(){var a=this,b=false;p(this.ra,function(c){var d=a.eval(c.s);if(d!==c.c){p(c.Fa,function(e){e(d,c.c);b=true});c.c=d}});return b}};na.prototype=
{ob:function(a){return fa.zb(a)},P:function(a,b,c,d){var e=this.tc+this.Tb++;a=this.ob(v({u:b,m:a,p:c}));b=Math.ceil(a.length/this.ma);c=this.url+"/$/"+e+"/"+b+"/";N[e]=function(h){delete N[e];d(200,h)};for(var f=0;f<b;f++){var g=a.substr(f*this.ma,this.ma);this.getScript(c+(f+1)+"?h="+g,n)}}};da.Bc="$DATASET:";da.prototype={P:J()};oa.prototype={P:function(a,b,c,d){var e=this;this.status.pb(c);this.xb.P(a,b,c,function(){e.status.Ab();try{d.apply(this,arguments)}catch(f){alert(v(f))}e.update()})}};
B(pa.prototype,{fetchCurrentUser:function(a){var b=this;this.nc.P("GET","/account.json",{},function(c,d){b.current=d.user;a(d.Oc)})},logout:function(a){var b=this;this.ha.Rb(function(){delete b.current;(a||n)()})},login:function(a){var b=this;this.ha.Qb(function(){b.fetchCurrentUser(function(){(a||n)()})})},notAuthorized:function(){this.ha.dc()}});p({regexp:function(a,b,c){return a.match(b)?null:c||"Value does not match expected format "+b+"."},number:function(a,b,c){var d=1*a;if(d==a){if(typeof b!=
-"undefined"&&d<b)return"Value can not be less than "+b+".";if(typeof b!="undefined"&&d>c)return"Value can not be greater than "+c+".";return null}else return"Value is not a number."},integer:function(a,b,c){b=Ga.number(a,b,c);if(b===null&&a!=Math.round(a))return"Value is not a whole number.";return b},date:function(a){if(a.match(/^\d\d?\/\d\d?\/\d\d\d\d$/))return null;return"Value is not a date. (Expecting format: 12/31/2009)."},ssn:function(a){if(a.match(/^\d\d\d-\d\d-\d\d\d\d$/))return null;return"SSN needs to be in 999-99-9999 format."},
-email:function(a){if(a.match(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/))return null;return"Email needs to be in username@host.com format."},phone:function(a){if(a.match(/^1\(\d\d\d\)\d\d\d-\d\d\d\d$/))return null;if(a.match(/^\+\d{2,3} (\(\d{1,5}\))?[\d ]+\d$/))return null;return"Phone number needs to be in 1(987)654-3210 format in North America or +999 (123) 45678 906 internationaly."},url:function(a){if(a.match(/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/))return null;
+"undefined"&&d<b)return"Value can not be less than "+b+".";if(typeof b!="undefined"&&d>c)return"Value can not be greater than "+c+".";return null}else return"Value is not a number."},integer:function(a,b,c){if(b=Ga.number(a,b,c))return b;if(!(""+a).match(/^\s*[\d+]*\s*$/)||a!=Math.round(a))return"Value is not a whole number.";return null},date:function(a){if(a.match(/^\d\d?\/\d\d?\/\d\d\d\d$/))return null;return"Value is not a date. (Expecting format: 12/31/2009)."},ssn:function(a){if(a.match(/^\d\d\d-\d\d-\d\d\d\d$/))return null;
+return"SSN needs to be in 999-99-9999 format."},email:function(a){if(a.match(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/))return null;return"Email needs to be in username@host.com format."},phone:function(a){if(a.match(/^1\(\d\d\d\)\d\d\d-\d\d\d\d$/))return null;if(a.match(/^\+\d{2,3} (\(\d{1,5}\))?[\d ]+\d$/))return null;return"Phone number needs to be in 1(987)654-3210 format in North America or +999 (123) 45678 906 internationaly."},url:function(a){if(a.match(/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/))return null;
return"URL needs to be in http://server[:port]/path format."},json:function(a){try{L(a);return null}catch(b){return b.toString()}}},function(a,b){Ga[b]=a});ma.prototype={tb:function(a,b){var c,d=a.attr("type").toLowerCase(),e=a.attr("name");if(e)e=e.split(":").pop();var f="change",g=true,h=ga[a.attr("ng-format")]||ga.noop;if(d=="button"||d=="submit"||d=="reset"||d=="image"){c=new Ra(a[0],e,h);f="click";g=false}else if(d=="text"||d=="textarea"||d=="hidden"||d=="password"){c=new ra(a[0],e,h);f="keyup change"}else if(d==
"checkbox"){c=new sa(a[0],e,h);f="click"}else if(d=="radio"){c=new va(a[0],e,h);f="click"}else if(d=="select-one")c=new ta(a[0],e,h);else if(d=="select-multiple")c=new ua(a[0],e,h);else if(d=="file")c=this.ub(a,e,h);else throw"Unknown type: "+d;a.data("controller",c);var i=b.get("$updateView");k(c.view,":input").bind(f,function(){if(c.e(b)){var j=k(c.view).attr("ng-action")||"";b.l(c,j)&&i(b)}return g});return c},ub:function(a){var b="__uploadWidget_"+this.Ub++,c=U.template(b);a.after(c);b=this.vb({data:this.ea+
"/admin/ServerAPI.swf",width:"95",height:"20",align:"top",wmode:"transparent"},{flashvars:"uploadWidgetId="+b,allowScriptAccess:"always"},b);a.remove();a=new U(c,a[0].name,b,this.ea+"/data/"+this.ja);k(b).data("controller",a);return a}};N.flashEvent=function(a,b,c){a=x.getElementById(a);a=k(a);var d=a.data("controller");U.prototype[b].apply(d,c);_.defer(a.scope().get("$updateView"))};U.template=function(a){return k('<span class="ng-upload-widget"><input type="checkbox" ng-non-bindable="true"/><object id="'+
diff --git a/angular.js b/angular.js
index 964f6baa..d329ede2 100644
--- a/angular.js
+++ b/angular.js
@@ -3192,11 +3192,12 @@ foreach({
},
'integer': function(value, min, max) {
- var number = angularValidator['number'](value, min, max);
- if (number === null && value != Math.round(value)) {
+ var numberError = angularValidator['number'](value, min, max);
+ if (numberError) return numberError;
+ if (!("" + value).match(/^\s*[\d+]*\s*$/) || value != Math.round(value)) {
return "Value is not a whole number.";
}
- return number;
+ return null;
},
'date': function(value, min, max) {
diff --git a/example/memoryLeak.html b/example/memoryLeak.html
new file mode 100644
index 00000000..35169da8
--- /dev/null
+++ b/example/memoryLeak.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <script type="text/javascript" src="../lib/underscore/underscore.js"></script>
+ <script type="text/javascript" src="../lib/jquery/jquery-1.3.2.js"></script>
+ <script type="text/javascript" src="../src/angular-bootstrap.js"></script>
+ <script type="text/javascript">
+ $(document).ready(function(){
+ angular.compile(document).init();
+ });
+ </script>
+ <link rel="StyleSheet" type="text/css" href="../css/angular.css"/>
+ </head>
+ <body>
+ Filter: <input name="filterText">
+ <ul ng-init="names=['misko']">
+ <li ng-repeat="name in names.$filter(filterText)">
+ <a href="" ng-action="greet(name)">{{name}}</a>
+ </li>
+ </ul>
+ </body>
+</html>
diff --git a/src/Validators.js b/src/Validators.js
index 5549ee39..84681f15 100644
--- a/src/Validators.js
+++ b/src/Validators.js
@@ -24,11 +24,12 @@ foreach({
},
'integer': function(value, min, max) {
- var number = angularValidator['number'](value, min, max);
- if (number === null && value != Math.round(value)) {
+ var numberError = angularValidator['number'](value, min, max);
+ if (numberError) return numberError;
+ if (!("" + value).match(/^\s*[\d+]*\s*$/) || value != Math.round(value)) {
return "Value is not a whole number.";
}
- return number;
+ return null;
},
'date': function(value, min, max) {
diff --git a/test/ValidatorsTest.js b/test/ValidatorsTest.js
index 22c7f390..f06e0b3a 100644
--- a/test/ValidatorsTest.js
+++ b/test/ValidatorsTest.js
@@ -19,6 +19,8 @@ ValidatorTest.prototype.testNumber = function() {
ValidatorTest.prototype.testInteger = function() {
assertEquals(angular.validator.integer("ab"), "Value is not a number.");
assertEquals(angular.validator.integer("1.1"), "Value is not a whole number.");
+ assertEquals(angular.validator.integer("1.0"), "Value is not a whole number.");
+ assertEquals(angular.validator.integer("1."), "Value is not a whole number.");
assertEquals(angular.validator.integer("-1",0), "Value can not be less than 0.");
assertEquals(angular.validator.integer("11",0,10), "Value can not be greater than 10.");
assertEquals(angular.validator.integer("1"), null);