diff --git a/lib/angular-placeholder.js b/lib/angular-placeholder.js index bd1d9e7..fa216b6 100644 --- a/lib/angular-placeholder.js +++ b/lib/angular-placeholder.js @@ -75,8 +75,8 @@ angular.module('ng.shims.placeholder', []) // handler for model-less inputs to interact with non-angular code if (!ngModel) { - elem.bind('change', function () { - changePlaceholder($interpolate(elem.attr('placeholder') || '')(scope)); + elem.bind('change', function (event) { + changePlaceholder($interpolate(elem.attr('placeholder') || '')(scope), event); }); } @@ -109,16 +109,16 @@ angular.module('ng.shims.placeholder', []) documentListenersApplied = true; } - function updateValue(e) { + function updateValue(event) { var val = elem.val(); // don't update from placeholder, helps debounce if (elem.hasClass(emptyClassName) && val && val === text) { return; } - conditionalDefer(function(){ setValue(val); }); + conditionalDefer(function(){ setValue(val); }, event); } - function conditionalDefer(callback) { + function conditionalDefer(callback, event) { // IE8/9: ngModel uses a keydown handler with deferrered // execution to check for changes to the input. this $timeout // prevents callback from firing before the keydown handler, @@ -127,7 +127,7 @@ angular.module('ng.shims.placeholder', []) // // TODO: remove this function when tab key behavior is fixed in // angular core - if (document.documentMode <= 11) { + if (document.documentMode <= 11 && event) { $timeout(callback, 0); } else { callback(); @@ -174,12 +174,12 @@ angular.module('ng.shims.placeholder', []) return val; } - function changePlaceholder(value) { + function changePlaceholder(value, event) { if (elem.hasClass(emptyClassName) && elem.val() === text) { elem.val(''); } text = value; - updateValue(); + updateValue(event); } // IE9: getting activeElement in an iframe raises error