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

Commit 930791b

Browse files
committed
tests(jQuery): make the tests pass on jQuery 3.0.0-beta1
1 parent 9743755 commit 930791b

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
@@ -1013,11 +1013,24 @@ describe('jqLite', function() {
10131013
'<option>test 2</option>' +
10141014
'</select>').val()).toEqual(['test 1']);
10151015

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

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)