aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/directive/input.js
diff options
context:
space:
mode:
authorChia-liang Kao2013-10-29 00:42:47 +0800
committerTobias Bosch2013-11-21 09:46:33 -0800
commita4e6d962d78b26f5112d48c4f88c1e6234d0cae7 (patch)
tree58d54c21558d4916e26ecec1f27c6ad4580f3b8e /src/ng/directive/input.js
parent7874a4d007f6e664f9d26e36ad4ab6e151b51ed7 (diff)
downloadangular.js-a4e6d962d78b26f5112d48c4f88c1e6234d0cae7.tar.bz2
feat(input): hold listener during text composition
When composing text in CJKV, intermediate buffer for unfinished text should not be updating the bound scope variables. Closes #4684
Diffstat (limited to 'src/ng/directive/input.js')
-rw-r--r--src/ng/directive/input.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js
index e264db38..ea4d84f4 100644
--- a/src/ng/directive/input.js
+++ b/src/ng/directive/input.js
@@ -392,8 +392,21 @@ var inputType = {
function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
+ // In composition mode, users are still inputing intermediate text buffer,
+ // hold the listener until composition is done.
+ // More about composition events: https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent
+ var composing = false;
+
+ element.on('compositionstart', function() {
+ composing = true;
+ });
+
+ element.on('compositionend', function() {
+ composing = false;
+ });
var listener = function() {
+ if (composing) return;
var value = element.val();
// By default we will trim the value