This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +28
-1
lines changed
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -1351,7 +1351,9 @@ function addSetValidityMethod(context) {
1351
1351
function isObjectEmpty ( obj ) {
1352
1352
if ( obj ) {
1353
1353
for ( var prop in obj ) {
1354
- return false ;
1354
+ if ( obj . hasOwnProperty ( prop ) ) {
1355
+ return false ;
1356
+ }
1355
1357
}
1356
1358
}
1357
1359
return true ;
Original file line number Diff line number Diff line change @@ -1091,6 +1091,31 @@ describe('ngModel', function() {
1091
1091
} ) ) ;
1092
1092
1093
1093
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
+
1094
1119
it ( 'should re-evaluate the form validity state once the asynchronous promise has been delivered' ,
1095
1120
inject ( function ( $compile , $rootScope , $q ) {
1096
1121
You can’t perform that action at this time.
0 commit comments