Skip to content

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 angular#6058
Closes angular#5433
  • Loading branch information
caitp authored and Sebastien Armand - sa250111 committed Feb 19, 2014
1 parent 4f09a51 commit be20e58
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 be20e58

Please sign in to comment.