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

Commit 8b9e6c3

Browse files
committed
fix(scenario): don't trigger input events on IE9
input.enter() should trigger 'change' rather than 'input' event on IE9 because input events on IE9 are broken and angular doesn't rely on them
1 parent c97c53d commit 8b9e6c3

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

src/ngScenario/dsl.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,13 @@ angular.scenario.dsl('binding', function() {
198198
*/
199199
angular.scenario.dsl('input', function() {
200200
var chain = {};
201-
var supportInputEvent = 'oninput' in document.createElement('div');
201+
var supportInputEvent = 'oninput' in document.createElement('div') && msie != 9;
202202

203203
chain.enter = function(value, event) {
204204
return this.addFutureAction("input '" + this.name + "' enter '" + value + "'", function($window, $document, done) {
205205
var input = $document.elements('[ng\\:model="$1"]', this.name).filter(':input');
206206
input.val(value);
207-
input.trigger(event || supportInputEvent && 'input' || 'change');
207+
input.trigger(event || (supportInputEvent ? 'input' : 'change'));
208208
done();
209209
});
210210
};

test/ngScenario/dslSpec.js

+17-7
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ describe("angular.scenario.dsl", function() {
269269
$root.dsl.select('test').options('A', 'B');
270270
expect($root.futureError).toMatch(/did not match/);
271271
});
272-
272+
273273
it('should fail to select an option that does not exist', function(){
274274
doc.append(
275275
'<select ng-model="test">' +
@@ -596,12 +596,22 @@ describe("angular.scenario.dsl", function() {
596596
});
597597

598598
describe('Input', function() {
599-
it('should change value in text input', function() {
600-
doc.append('<input ng-model="test.input" value="something">');
601-
var chain = $root.dsl.input('test.input');
602-
chain.enter('foo');
603-
expect(_jQuery('input[ng-model="test.input"]').val()).toEqual('foo');
604-
});
599+
it('should change value in text input', inject(function($compile) {
600+
runs(function() {
601+
element = $compile('<input ng-model="test.input" value="something">')($root);
602+
doc.append(element);
603+
var chain = $root.dsl.input('test.input');
604+
chain.enter('foo');
605+
expect(_jQuery('input[ng-model="test.input"]').val()).toEqual('foo');
606+
});
607+
608+
// cleanup the event queue
609+
waits(0);
610+
611+
runs(function() {
612+
expect($root.test.input).toBe('foo');
613+
});
614+
}));
605615

606616
it('should change value in text input in dash form', function() {
607617
doc.append('<input ng-model="test.input" value="something">');

0 commit comments

Comments
 (0)