From 44f8bc0480d4691254c1b8a64b1ff6e7bec2ddf3 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Mon, 16 Dec 2013 13:06:16 -0500 Subject: [PATCH] fix(input): setViewValue on compositionend Because of a4e6d962, model is not updated on input/change between the compositionstart and compositionend events. Unfortunately, the compositionend event does not always happen prior to an input/change event. This changeset calls the listener function to update the model after a compositionend event is received. --- src/ng/directive/input.js | 1 + test/ng/directive/inputSpec.js | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index 85d0f22ddc85..f150ba682223 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -447,6 +447,7 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) { element.on('compositionend', function() { composing = false; + listener(); }); } diff --git a/test/ng/directive/inputSpec.js b/test/ng/directive/inputSpec.js index 668fa0b54a1e..b9f737ac0593 100644 --- a/test/ng/directive/inputSpec.js +++ b/test/ng/directive/inputSpec.js @@ -509,6 +509,17 @@ describe('input', function() { }); } + it('should update the model on "compositionend"', function() { + compileInput(''); + if (!(msie < 9)) { + browserTrigger(inputElm, 'compositionstart'); + changeInputValueTo('caitp'); + expect(scope.name).toBeUndefined(); + browserTrigger(inputElm, 'compositionend'); + expect(scope.name).toEqual('caitp'); + } + }); + describe('"change" event', function() { function assertBrowserSupportsChangeEvent(inputEventSupported) { // Force browser to report a lack of an 'input' event