-
Notifications
You must be signed in to change notification settings - Fork 27.4k
patternDirective does not adhere to as how pattern is specified in HTML5 #9881
Comments
Correct support for pattern is possible, but the changes to ng-pattern would be breaking. |
Sorry, you are right |
Wait a second ... it's not exactly the same. If |
@matsko had fixed this a while ago --- but it's likely that 1.2.x is not using the updated code. |
What, this is on 1.2.x. No wonder I am confused. |
Wait, the plunkr is not in 1.2.x, it's 1.3.1. I'm out for now, will investigate later. |
oh I see, yeah. so there is a bug still. The issue seems to be this: https://github.com/angular/angular.js/blob/master/src/ng/directive/input.js#L2579-L2581 in HTML, pattern is a regexp pattern which matches the entire string --- so basically the equivalent of |
From https://html.spec.whatwg.org/multipage/forms.html#attr-input-pattern > The compiled pattern regular expression, when matched against a string, must have its start anchored to the start of the string and its end anchored to the end of the string. Closes angular#9881
On an input like that
Angular accepts an input of four or more digits, while browsers only accept an input of exactly four digits. See http://plnkr.co/edit/9LeAPND933Byv4uQ3dT9?p=preview
The reason behind this, is that the standard implies the pattern to have to match the whole string [1]:
In my opinion, Angular should follow the spec. Yet I am aware that a fix would be a breaking change.
[1] https://html.spec.whatwg.org/multipage/forms.html#attr-input-pattern
The text was updated successfully, but these errors were encountered: