This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -1351,7 +1351,9 @@ function addSetValidityMethod(context) {
13511351function isObjectEmpty ( obj ) {
13521352 if ( obj ) {
13531353 for ( var prop in obj ) {
1354- return false ;
1354+ if ( obj . hasOwnProperty ( prop ) ) {
1355+ return false ;
1356+ }
13551357 }
13561358 }
13571359 return true ;
Original file line number Diff line number Diff line change @@ -1091,6 +1091,31 @@ describe('ngModel', function() {
10911091 } ) ) ;
10921092
10931093
1094+ it ( 'should be possible to extend Object prototype and still be able to do form validation' ,
1095+ inject ( function ( $compile , $rootScope ) {
1096+ Object . prototype . someThing = function ( ) { } ;
1097+ var element = $compile ( '<form name="myForm">' +
1098+ '<input type="text" name="username" ng-model="username" minlength="10" required />' +
1099+ '</form>' ) ( $rootScope ) ;
1100+ var inputElm = element . find ( 'input' ) ;
1101+
1102+ var formCtrl = $rootScope . myForm ;
1103+ var usernameCtrl = formCtrl . username ;
1104+
1105+ $rootScope . $digest ( ) ;
1106+ expect ( usernameCtrl . $invalid ) . toBe ( true ) ;
1107+ expect ( formCtrl . $invalid ) . toBe ( true ) ;
1108+
1109+ usernameCtrl . $setViewValue ( 'valid-username' ) ;
1110+ $rootScope . $digest ( ) ;
1111+
1112+ expect ( usernameCtrl . $invalid ) . toBe ( false ) ;
1113+ expect ( formCtrl . $invalid ) . toBe ( false ) ;
1114+ delete Object . prototype . someThing ;
1115+
1116+ dealoc ( element ) ;
1117+ } ) ) ;
1118+
10941119 it ( 'should re-evaluate the form validity state once the asynchronous promise has been delivered' ,
10951120 inject ( function ( $compile , $rootScope , $q ) {
10961121
You can’t perform that action at this time.
0 commit comments