aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMark Dalgleish2013-03-21 18:07:49 +1100
committerPete Bacon Darwin2013-04-17 21:50:07 +0100
commit3ebc2c2442755aa93a908b0ee9e372c8e6e4a924 (patch)
tree92617220371a5586ad23b02025d0c6de5191ba54 /src
parent631d86f723a27c079784c62d2807650183729cb3 (diff)
downloadangular.js-3ebc2c2442755aa93a908b0ee9e372c8e6e4a924.tar.bz2
fix(ngModel): use paste/cut events in IE to support context menu
In IE the model is not updated when the input value is modified using the context menu, e.g. pasting from the clipboard, or cutting all or part of the current value. To capture these changes, we bind to the proprietary 'paste' and 'cut' events. Closes #1462
Diffstat (limited to 'src')
-rw-r--r--src/ng/directive/input.js21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js
index aed43313..828f2812 100644
--- a/src/ng/directive/input.js
+++ b/src/ng/directive/input.js
@@ -398,6 +398,15 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
} else {
var timeout;
+ var deferListener = function() {
+ if (!timeout) {
+ timeout = $browser.defer(function() {
+ listener();
+ timeout = null;
+ });
+ }
+ };
+
element.bind('keydown', function(event) {
var key = event.keyCode;
@@ -405,16 +414,16 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
// command modifiers arrows
if (key === 91 || (15 < key && key < 19) || (37 <= key && key <= 40)) return;
- if (!timeout) {
- timeout = $browser.defer(function() {
- listener();
- timeout = null;
- });
- }
+ deferListener();
});
// if user paste into input using mouse, we need "change" event to catch it
element.bind('change', listener);
+
+ // if user modifies input value using context menu in IE, we need "paste" and "cut" events to catch it
+ if ($sniffer.hasEvent('paste')) {
+ element.bind('paste cut', deferListener);
+ }
}