Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit bd59335

Browse files
lgalfasopetebacondarwin
authored andcommitted
test(input): test for #12106
Add a test that checks that an <input> value is not set when the value is equal to the current value Closes #12592
1 parent 6aa111b commit bd59335

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/ng/directive/inputSpec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,25 @@ describe('input', function() {
7272
expect($rootScope.form.$$renameControl).not.toHaveBeenCalled();
7373
});
7474

75+
76+
it('should not set the `val` property when the value is equal to the current value', inject(function($rootScope, $compile) {
77+
// This is a workaround for Firefox validation. Look at #12102.
78+
var input = jqLite('<input type="text" ng-model="foo" required/>');
79+
var setterCalls = 0;
80+
$rootScope.foo = '';
81+
Object.defineProperty(input[0], 'value', {
82+
get: function() {
83+
return '';
84+
},
85+
set: function() {
86+
setterCalls++;
87+
}
88+
});
89+
$compile(input)($rootScope);
90+
$rootScope.$digest();
91+
expect(setterCalls).toBe(0);
92+
}));
93+
7594
describe('compositionevents', function() {
7695
it('should not update the model between "compositionstart" and "compositionend" on non android', function() {
7796

0 commit comments

Comments
 (0)