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

feat(input): added drop event support #16420

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ng/directive/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -1306,9 +1306,9 @@ function baseInputType(scope, element, attr, ctrl, $sniffer, $browser) {
deferListener(event, this, this.value);
});

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

Expand Down
14 changes: 13 additions & 1 deletion test/ng/directive/inputSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ describe('input', function() {
}
});

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

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

browserTrigger(inputElm, 'keydown');
$browser.defer.flush();
expect(inputElm).toBePristine();

inputElm.val('mark');
browserTrigger(inputElm, 'drop');
$browser.defer.flush();
expect($rootScope.name).toEqual('mark');
});

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