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

Commit

Permalink
fix(input): update $viewValue when cleared
Browse files Browse the repository at this point in the history
- Fix when user clicks clear button in an input element in IE, $viewValue not being correctly updated
  • Loading branch information
wesleycho committed Jun 14, 2016
1 parent 9686f3a commit 0bf2e0a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/ng/directive/input.js
Expand Up @@ -1126,7 +1126,7 @@ function baseInputType(scope, element, attr, ctrl, $sniffer, $browser) {
});
}

var timeout;
var timeout, oldVal;

var listener = function(ev) {
if (timeout) {
Expand All @@ -1152,10 +1152,17 @@ function baseInputType(scope, element, attr, ctrl, $sniffer, $browser) {
}
};

function ieListener(ev) {
var val = element.val();
if (val === oldVal) return;
oldVal = val;
listener(ev);
}

// if the browser does support "input" event, we are fine - except on IE9 which doesn't fire the
// input event on backspace, delete or cut
if ($sniffer.hasEvent('input')) {
element.on('input', listener);
element.on('input', msie ? ieListener : listener);
} else {
var deferListener = function(ev, input, origValue) {
if (!timeout) {
Expand Down

0 comments on commit 0bf2e0a

Please sign in to comment.