diff options
| author | Michał Gołębiowski | 2013-12-05 14:59:13 +0100 |
|---|---|---|
| committer | Igor Minar | 2013-12-30 15:09:49 -0800 |
| commit | 1147f21999edf9a434cd8d24865a6455e744d858 (patch) | |
| tree | 259a8f54f69f1d3273b598ff912ca22ca8d5a334 /test/ng/directive | |
| parent | bddd46c8ecf49cfe6c999cd6b4a69b7d7e1f9a33 (diff) | |
| download | angular.js-1147f21999edf9a434cd8d24865a6455e744d858.tar.bz2 | |
fix(input): prevent double $digest when using jQuery trigger.
If an event was performed natively, jQuery sets the isTrigger property.
When triggering event manually, the field is not present. Manually
triggered events are performed synchronously which causes the "$digest
already in progress" error.
Closes #5293
Diffstat (limited to 'test/ng/directive')
| -rw-r--r-- | test/ng/directive/inputSpec.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/ng/directive/inputSpec.js b/test/ng/directive/inputSpec.js index 48319cfa..c9a345cd 100644 --- a/test/ng/directive/inputSpec.js +++ b/test/ng/directive/inputSpec.js @@ -533,6 +533,23 @@ describe('input', function() { 'event so that form auto complete works',function() { assertBrowserSupportsChangeEvent(true); }); + + if (!_jqLiteMode) { + it('should not cause the double $digest when triggering an event using jQuery', function() { + $sniffer.hasEvent = function(eventName) { + return eventName !== 'input'; + }; + + compileInput('<input type="text" ng-model="name" name="alias" ng-change="change()" />'); + + scope.field = 'fake field'; + scope.$watch('field', function() { + // We need to use _originalTrigger since trigger is modified by Angular Scenario. + inputElm._originalTrigger('change'); + }); + scope.$apply(); + }); + } }); describe('"paste" and "cut" events', function() { |
