Skip to content

Commit 204eb93

Browse files
authored
Merge pull request #364 from jakerella/jquery-4.0.0-beta.2
Support for jquery 4.0.0-beta
2 parents 4ca7ace + 0adc9b9 commit 204eb93

12 files changed

+9770
-50
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 2024-09-09 v2.7.0-beta.0
2+
* Support for jQuery 4.0.0-beta
3+
* Removed deprecated calls to $.isArray() and $.isFunction()
4+
* Updated cross-origin tests to use a safe domain
5+
* Thanks to @jayaddison for the nudge and PR!
6+
17
## 2024-02-17 v2.6.1
28
* Changed license from dual (MIT & GPL) to only be MIT
39
* Updated authorship to myself (creator of all v2 changes) and moved JD Sharp to contributor

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ Currently, @jakerella is the only one doing so.
155155
1. Update the `CHANGELOG.md`, `package.json` version, and any other necessary files.
156156
(Note that these can be in a commit, but put them in that new branch.)
157157
1. Make sure to generate fresh dist files if necessary and commit those.
158-
1. Submit a PR for the branch, this will initiate the Travis CI checks.
158+
1. Submit a PR for the branch, fill out all of the necessary details.
159159
1. Ask others for input on the PR (mostly testing in their own browsers).
160160
1. *If all is well*, merge the branch into `master`
161161
1. Create a release on Github with a tag matching the version number and proper info.

dist/jquery.mockjax.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*! jQuery Mockjax
22
* A Plugin providing simple and flexible mocking of ajax requests and responses
33
*
4-
* Version: 2.6.0
4+
* Version: 2.7.0-beta.0
55
* Home: https://github.com/jakerella/jquery-mockjax
66
* Copyright (c) 2024 Jordan Kasper, formerly appendTo;
77
* NOTE: This repository was taken over by Jordan Kasper (@jakerella) October, 2014
@@ -78,14 +78,14 @@
7878
logger.debug( mock, ['Checking mock data against request data', mock, live] );
7979
var identical = true;
8080

81-
if ( $.isFunction(mock) ) {
81+
if (typeof mock === 'function') {
8282
return !!mock(live);
8383
}
8484

8585
// Test for situations where the data is a querystring (not an object)
8686
if (typeof live === 'string') {
8787
// Querystring may be a regex
88-
if ($.isFunction( mock.test )) {
88+
if (typeof mock.test === 'function') {
8989
return mock.test(live);
9090
} else if (typeof mock === 'object') {
9191
live = getQueryParams(live);
@@ -100,12 +100,12 @@
100100
return identical;
101101
} else {
102102
if ( typeof live[k] === 'object' && live[k] !== null ) {
103-
if ( identical && $.isArray( live[k] ) ) {
104-
identical = $.isArray( mock[k] ) && live[k].length === mock[k].length;
103+
if ( identical && Array.isArray( live[k] ) ) {
104+
identical = Array.isArray( mock[k] ) && live[k].length === mock[k].length;
105105
}
106106
identical = identical && isMockDataEqual(mock[k], live[k]);
107107
} else {
108-
if ( mock[k] && $.isFunction( mock[k].test ) ) {
108+
if ( mock[k] && typeof mock[k].test === 'function') {
109109
identical = identical && mock[k].test(live[k]);
110110
} else {
111111
identical = identical && ( mock[k] === live[k] );
@@ -160,7 +160,7 @@
160160
function getMockForRequest( handler, requestSettings ) {
161161
// If the mock was registered with a function, let the function decide if we
162162
// want to mock this request
163-
if ( $.isFunction(handler) ) {
163+
if (typeof handler === 'function') {
164164
return handler( requestSettings );
165165
}
166166

@@ -169,7 +169,7 @@
169169

170170
// Inspect the URL of the request and check if the mock handler's url
171171
// matches the url for this ajax request
172-
if ( $.isFunction(handler.url.test) ) {
172+
if (typeof handler.url.test === 'function') {
173173
// namespace exists prepend handler.url with namespace
174174
if (!!namespace) {
175175
namespace = namespace.replace(/(\/+)$/, '');
@@ -243,7 +243,7 @@
243243
}
244244

245245
function parseResponseTimeOpt(responseTime) {
246-
if ($.isArray(responseTime) && responseTime.length === 2) {
246+
if (Array.isArray(responseTime) && responseTime.length === 2) {
247247
var min = responseTime[0];
248248
var max = responseTime[1];
249249
if(isPosNum(min) && isPosNum(max)) {
@@ -292,7 +292,7 @@
292292
this.responseText = mockHandler.responseText;
293293
}
294294

295-
if ($.isArray(mockHandler.status)) {
295+
if (Array.isArray(mockHandler.status)) {
296296
var idxStatus = Math.floor(Math.random() * mockHandler.status.length);
297297
this.status = mockHandler.status[idxStatus];
298298
} else if (typeof mockHandler.status === 'number' || typeof mockHandler.status === 'string') {
@@ -306,7 +306,7 @@
306306
onReady = this.onload || this.onreadystatechange;
307307

308308
// jQuery < 1.4 doesn't have onreadystate change for xhr
309-
if ( $.isFunction( onReady ) ) {
309+
if (typeof onReady === 'function') {
310310
if( mockHandler.isTimeout) {
311311
this.status = -1;
312312
}
@@ -319,7 +319,7 @@
319319

320320
// We have an executable function, call it to give
321321
// the mock handler a chance to update it's data
322-
if ( $.isFunction(mockHandler.response) ) {
322+
if (typeof mockHandler.response === 'function') {
323323
// Wait for it to finish
324324
if ( mockHandler.response.length === 2 ) {
325325
mockHandler.response(origSettings, function () {
@@ -495,7 +495,7 @@
495495
newMock = ($.Deferred) ? (new $.Deferred()) : null;
496496

497497
// If the response handler on the moock is a function, call it
498-
if ( mockHandler.response && $.isFunction(mockHandler.response) ) {
498+
if ( mockHandler.response && typeof mockHandler.response === 'function' ) {
499499

500500
mockHandler.response(origSettings);
501501

@@ -545,7 +545,7 @@
545545

546546
if ( newMock ) {
547547
try {
548-
json = $.parseJSON( mockHandler.responseText );
548+
json = JSON.parse( mockHandler.responseText );
549549
} catch (err) { /* just checking... */ }
550550

551551
newMock.resolveWith( callbackContext, [json || mockHandler.responseText] );
@@ -641,7 +641,7 @@
641641
overrideCallback = function(action, mockHandler) {
642642
var origHandler = origSettings[action.toLowerCase()];
643643
return function() {
644-
if ( $.isFunction(origHandler) ) {
644+
if (typeof origHandler === 'function') {
645645
origHandler.apply(this, [].slice.call(arguments));
646646
}
647647
mockHandler['onAfter' + action]();
@@ -725,13 +725,13 @@
725725
}
726726

727727
// Set up onAfter[X] callback functions
728-
if ( $.isFunction( mockHandler.onAfterSuccess ) ) {
728+
if (typeof mockHandler.onAfterSuccess === 'function') {
729729
origSettings.success = overrideCallback('Success', mockHandler);
730730
}
731-
if ( $.isFunction( mockHandler.onAfterError ) ) {
731+
if (typeof mockHandler.onAfterError === 'function') {
732732
origSettings.error = overrideCallback('Error', mockHandler);
733733
}
734-
if ( $.isFunction( mockHandler.onAfterComplete ) ) {
734+
if (typeof mockHandler.onAfterComplete === 'function') {
735735
origSettings.complete = overrideCallback('Complete', mockHandler);
736736
}
737737

@@ -935,7 +935,7 @@
935935
*/
936936
$.mockjax = function(settings) {
937937
// Multiple mocks.
938-
if ( $.isArray(settings) ) {
938+
if (Array.isArray(settings)) {
939939
return $.map(settings, function(s) {
940940
return $.mockjax(s);
941941
});

dist/jquery.mockjax.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

grunt-config-options.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ module.exports = {
6464
jQueryVersions: [
6565
'1.12.4',
6666
'2.2.4',
67-
'3.7.1'
67+
'3.7.1',
68+
'4.0.0-beta.2'
6869
]
6970
},
7071
edge: {
@@ -75,7 +76,8 @@ module.exports = {
7576
jQueryVersions: [
7677
'1.12.4',
7778
'2.2.4',
78-
'3.7.1'
79+
'3.7.1',
80+
'4.0.0-beta.2'
7981
]
8082
},
8183
browserify: {

0 commit comments

Comments
 (0)