Skip to content

Commit 92c612a

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 a7b53ab commit 92c612a

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/ngScenario/dsl.js

Lines changed: 2 additions & 2 deletions
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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +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+
272273
});
273274

274275
describe('Element', function() {
@@ -553,12 +554,22 @@ describe("angular.scenario.dsl", function() {
553554
});
554555

555556
describe('Input', function() {
556-
it('should change value in text input', function() {
557-
doc.append('<input ng-model="test.input" value="something">');
558-
var chain = $root.dsl.input('test.input');
559-
chain.enter('foo');
560-
expect(_jQuery('input[ng-model="test.input"]').val()).toEqual('foo');
561-
});
557+
it('should change value in text input', inject(function($compile) {
558+
runs(function() {
559+
element = $compile('<input ng-model="test.input" value="something">')($root);
560+
doc.append(element);
561+
var chain = $root.dsl.input('test.input');
562+
chain.enter('foo');
563+
expect(_jQuery('input[ng-model="test.input"]').val()).toEqual('foo');
564+
});
565+
566+
// cleanup the event queue
567+
waits(0);
568+
569+
runs(function() {
570+
expect($root.test.input).toBe('foo');
571+
});
572+
}));
562573

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

0 commit comments

Comments
 (0)