Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix(input): setViewValue on compositionend
Browse files Browse the repository at this point in the history
Because of a4e6d96, 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.

Closes #6058
Closes #5433
  • Loading branch information
caitp committed Feb 13, 2014
1 parent 1079105 commit 2b73027
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ng/directive/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {

element.on('compositionend', function() {
composing = false;
listener();
});
}

Expand Down
11 changes: 11 additions & 0 deletions test/ng/directive/inputSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,17 @@ describe('input', function() {
});
}

it('should update the model on "compositionend"', function() {
compileInput('<input type="text" ng-model="name" name="alias" />');
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
Expand Down

0 comments on commit 2b73027

Please sign in to comment.