Skip to content

Commit cb2b0fd

Browse files
authored
Cancel previous timeout instead of ignoring events
This fixes the IE issue reported to AngularJS at angular#16519 Instead of ignoring key events, we cancel the previous deferred timeout and declare a new one each time. This fixes the problem that references to `input` and `origValue` inside the deferred function do not point to the most recent key event occurrence.
1 parent 55075b8 commit cb2b0fd

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

Diff for: src/ng/directive/input.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -1349,14 +1349,13 @@ function baseInputType(scope, element, attr, ctrl, $sniffer, $browser) {
13491349
element.on('input', listener);
13501350
} else {
13511351
var deferListener = function(ev, input, origValue) {
1352-
if (!timeout) {
1353-
timeout = $browser.defer(function() {
1354-
timeout = null;
1355-
if (!input || input.value !== origValue) {
1356-
listener(ev);
1357-
}
1358-
});
1359-
}
1352+
if (timeout) $browser.defer.cancel(timeout);
1353+
timeout = $browser.defer(function() {
1354+
timeout = null;
1355+
if (!input || input.value !== origValue) {
1356+
listener(ev);
1357+
}
1358+
});
13601359
};
13611360

13621361
element.on('keydown', /** @this */ function(event) {

0 commit comments

Comments
 (0)