$setViewValue makes invalid field blank if using attribute «pattern» #9986
Description
Plunker — http://plnkr.co/edit/54otaclvjjZUW63vR9QT?p=preview
There I have two input fields and two directives — the only difference in this fields and directives is that one has «pattern="a-z"» attribute and other has «blabla="a-z"» attribute.
The one with «pattern» attribute doesn't work — $setViewValue() makes it blank if it does not fit the pattern regexp.
So, what is the problem with this «pattern» attribute — why does it brake everything? Does Angular use both «pattern» and «ng-pattern» attribute to validate input field? Why «pattern» attribute makes field blank if it is not valid?
Also, I have changed «pattern» to «ng-pattern» and it resolved the problem:
<input type="text" name="foo" ng-pattern="a-z" ng-model="user.foo" working-input>
and in directive:
var pattern = attributes.ngPattern;
I'm creating this issue for those who has the same problem and spend about 30 minutes to resolve it (because renaming «pattern» attribute to something else really is not obvious).
(I have found some issues here but they all are about $asyncValidators)