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

Commit b8343e2

Browse files
mgolpetebacondarwin
authored andcommitted
tests(jQuery): make the tests pass on jQuery 3.0.0-beta1
Closes #14229
1 parent 5b2f6fa commit b8343e2

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

src/ngScenario/Application.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ angular.scenario.Application.prototype.navigateTo = function(url, loadFn, errorF
6464
self.context.find('#test-frames').append('<iframe>');
6565
frame = self.getFrame_();
6666

67-
frame.load(function() {
67+
frame.on('load', function() {
6868
frame.off();
6969
try {
7070
var $window = self.getWindow_();

test/jqLiteSpec.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -1017,11 +1017,24 @@ describe('jqLite', function() {
10171017
'<option>test 2</option>' +
10181018
'</select>').val()).toEqual(['test 1']);
10191019

1020+
// In jQuery >= 3.0 .val() on select[multiple] with no selected options returns an
1021+
// empty array, not null.
1022+
// See https://github.com/jquery/jquery/issues/2562 for more details.
1023+
// jqLite will align with jQuery 3.0 behavior in Angular 1.6.
1024+
var val;
1025+
var jQueryVersion = window.jQuery && window.jQuery.fn.jquery.split('.')[0];
1026+
var jQuery3xOrNewer = jQueryVersion && (Number(jQueryVersion) >= 3);
1027+
if (!_jqLiteMode && jQuery3xOrNewer) {
1028+
val = [];
1029+
} else {
1030+
val = null;
1031+
}
1032+
10201033
expect(jqLite(
10211034
'<select multiple>' +
10221035
'<option>test 1</option>' +
10231036
'<option>test 2</option>' +
1024-
'</select>').val()).toEqual(null);
1037+
'</select>').val()).toEqual(val);
10251038
});
10261039
});
10271040

test/ng/browserSpecs.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@ function MockWindow(options) {
4848

4949
this.fire = function(name) {
5050
forEach(events[name], function(fn) {
51-
fn({type: name}); // type to make jQuery happy
51+
// type/target to make jQuery happy
52+
fn({
53+
type: name,
54+
target: {
55+
nodeType: 1
56+
}
57+
});
5258
});
5359
};
5460

0 commit comments

Comments
 (0)