mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-01-12 22:45:52 +08:00
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.
Closes #6058
Closes #5433
This commit is contained in:
@@ -447,6 +447,7 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
|
||||
|
||||
element.on('compositionend', function() {
|
||||
composing = false;
|
||||
listener();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user