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

Commit a8830d2

Browse files
XFreepetebacondarwin
authored andcommitted
feat(input): add drop event support (#16420)
1 parent 8d9984e commit a8830d2

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/ng/directive/input.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1306,9 +1306,9 @@ function baseInputType(scope, element, attr, ctrl, $sniffer, $browser) {
13061306
deferListener(event, this, this.value);
13071307
});
13081308

1309-
// if user modifies input value using context menu in IE, we need "paste" and "cut" events to catch it
1309+
// if user modifies input value using context menu in IE, we need "paste", "cut" and "drop" events to catch it
13101310
if ($sniffer.hasEvent('paste')) {
1311-
element.on('paste cut', deferListener);
1311+
element.on('paste cut drop', deferListener);
13121312
}
13131313
}
13141314

test/ng/directive/inputSpec.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ describe('input', function() {
439439
}
440440
});
441441

442-
describe('"keydown", "paste" and "cut" events', function() {
442+
describe('"keydown", "paste", "cut" and "drop" events', function() {
443443
beforeEach(function() {
444444
// Force browser to report a lack of an 'input' event
445445
$sniffer.hasEvent = function(eventName) {
@@ -461,6 +461,18 @@ describe('input', function() {
461461
expect($rootScope.name).toEqual('mark');
462462
});
463463

464+
it('should update the model on "drop" event if the input value changes', function() {
465+
var inputElm = helper.compileInput('<input type="text" ng-model="name" name="alias" ng-change="change()" />');
466+
467+
browserTrigger(inputElm, 'keydown');
468+
$browser.defer.flush();
469+
expect(inputElm).toBePristine();
470+
471+
inputElm.val('mark');
472+
browserTrigger(inputElm, 'drop');
473+
$browser.defer.flush();
474+
expect($rootScope.name).toEqual('mark');
475+
});
464476

465477
it('should update the model on "cut" event', function() {
466478
var inputElm = helper.compileInput('<input type="text" ng-model="name" name="alias" ng-change="change()" />');

0 commit comments

Comments
 (0)