mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-01 12:33:37 +08:00
fix(input): bind inputs to the 'input' event
The input event is fired on all non-ie browsers whenever the contents of an input field changes. This means that we now support cut&paste via mouse which was previously unsupported. IE8 and older don't support this events and IE9 has a problematic support for it, so we can't rely solely on this event and drop keydown and change events.
This commit is contained in:
@@ -817,7 +817,7 @@ angularWidget('input', function(inputElement){
|
||||
inputElement.val(widget.$viewValue || '');
|
||||
};
|
||||
|
||||
inputElement.bind('keydown change', function(event){
|
||||
inputElement.bind('keydown change input', function(event) {
|
||||
var key = event.keyCode;
|
||||
if (/*command*/ key != 91 &&
|
||||
/*modifiers*/ !(15 < key && key < 19) &&
|
||||
|
||||
@@ -112,7 +112,7 @@ describe('widget: input', function() {
|
||||
describe("input", function() {
|
||||
|
||||
describe("text", function() {
|
||||
it('should input-text auto init and handle keydown/change events', function() {
|
||||
it('should input-text auto init and listen on keydown/change/input events', function() {
|
||||
compile('<input type="text" ng:model="name"/>');
|
||||
|
||||
scope.name = 'Adam';
|
||||
@@ -130,6 +130,13 @@ describe('widget: input', function() {
|
||||
browserTrigger(element, 'change');
|
||||
defer.flush();
|
||||
expect(scope.name).toEqual('Kai');
|
||||
|
||||
if (!(msie<=8)) {
|
||||
element.val('Lunar');
|
||||
browserTrigger(element, 'input');
|
||||
defer.flush();
|
||||
expect(scope.name).toEqual('Lunar');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user