mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-10 22:44:01 +08:00
fix(ngPattern): allow modifiers on inline ng-pattern
Add support for regex modifiers on inline `ng-pattern`. `ng-pattern="/regex/i"` now validates correctly. Closes #1437
This commit is contained in:
@@ -476,6 +476,18 @@ describe('input', function() {
|
||||
});
|
||||
|
||||
|
||||
it('should validate in-lined pattern with modifiers', function() {
|
||||
compileInput('<input type="text" ng-model="value" ng-pattern="/^abc?$/i" />');
|
||||
scope.$digest();
|
||||
|
||||
changeInputValueTo('aB');
|
||||
expect(inputElm).toBeValid();
|
||||
|
||||
changeInputValueTo('xx');
|
||||
expect(inputElm).toBeInvalid();
|
||||
});
|
||||
|
||||
|
||||
it('should validate pattern from scope', function() {
|
||||
compileInput('<input type="text" ng-model="value" ng-pattern="regexp" />');
|
||||
scope.regexp = /^\d\d\d-\d\d-\d\d\d\d$/;
|
||||
|
||||
Reference in New Issue
Block a user