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

Commit 5dc0766

Browse files
XFreepetebacondarwin
authored andcommitted
feat(input): add drop event support (#16420)
1 parent 212e513 commit 5dc0766

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/ng/directive/input.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,9 +1302,9 @@ function baseInputType(scope, element, attr, ctrl, $sniffer, $browser) {
13021302
deferListener(event, this, this.value);
13031303
});
13041304

1305-
// if user modifies input value using context menu in IE, we need "paste" and "cut" events to catch it
1305+
// if user modifies input value using context menu in IE, we need "paste", "cut" and "drop" events to catch it
13061306
if ($sniffer.hasEvent('paste')) {
1307-
element.on('paste cut', deferListener);
1307+
element.on('paste cut drop', deferListener);
13081308
}
13091309
}
13101310

test/ng/directive/inputSpec.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ describe('input', function() {
440440
}
441441
});
442442

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

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

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

0 commit comments

Comments
 (0)