Skip to content

Commit 244a8a1

Browse files
authored
Merge pull request #1467 from OpenGeoscience/jquery-4
feat: Switch to jQuery 4
2 parents fb89f5f + 380c65c commit 244a8a1

File tree

9 files changed

+30
-19
lines changed

9 files changed

+30
-19
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"gl-mat4": "^1.2.0",
2222
"gl-vec3": "^1.1.3",
2323
"gl-vec4": "^1.0.1",
24-
"jquery": "^3.6.0",
24+
"jquery": "^4.0.0",
2525
"kdbush": "^4.0.0",
2626
"mousetrap": "^1.6.5",
2727
"proj4": "^2.7.5"

src/map.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ var map = function (arg) {
10041004
throw new Error('Map require DIV node');
10051005
}
10061006

1007-
if (m_node.data('data-geojs-map') && $.isFunction(m_node.data('data-geojs-map').exit)) {
1007+
if (m_node.data('data-geojs-map') && typeof m_node.data('data-geojs-map').exit === 'function') {
10081008
m_node.data('data-geojs-map').exit();
10091009
}
10101010
m_node.addClass('geojs-map');

src/tileLayer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ var tileLayer = function (arg) {
205205
// (math.ceil(min(w, h) / (ts*2**l)) + 1) for l in range(ml)])
206206
arg.cacheSize = arg.keepLower ? 600 : 200;
207207
}
208-
if ($.type(arg.subdomains) === 'string') {
208+
if (typeof arg.subdomains === 'string') {
209209
arg.subdomains = arg.subdomains.split('');
210210
}
211211
/* We used to call the url option baseUrl. If a baseUrl is specified, use
@@ -219,7 +219,7 @@ var tileLayer = function (arg) {
219219
}
220220
/* Save the original url so that we can return it if asked */
221221
arg.originalUrl = arg.url;
222-
if ($.type(arg.url) === 'string') {
222+
if (typeof arg.url === 'string') {
223223
arg.url = m_tileUrlFromTemplate(arg.url);
224224
}
225225

@@ -1636,7 +1636,7 @@ var tileLayer = function (arg) {
16361636
return m_this;
16371637
}
16381638
m_this._options.originalUrl = url;
1639-
if ($.type(url) === 'string') {
1639+
if (typeof url === 'string') {
16401640
url = m_tileUrlFromTemplate(url);
16411641
}
16421642
m_this._options.url = url;
@@ -1657,7 +1657,7 @@ var tileLayer = function (arg) {
16571657
return m_this._options.subdomains;
16581658
}
16591659
if (subdomains) {
1660-
if ($.type(subdomains) === 'string') {
1660+
if (typeof subdomains === 'string') {
16611661
if (subdomains.indexOf(',') >= 0) {
16621662
subdomains = subdomains.split(',');
16631663
} else {

src/util/common.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -380,15 +380,15 @@ var util = {
380380
var action, i;
381381
for (i = 0; i < actions.length; i += 1) {
382382
action = actions[i];
383-
if ($.type(action.input) === 'string') {
383+
if (typeof action.input === 'string') {
384384
var actionEvents = {};
385385
actionEvents[action.input] = true;
386386
action.input = actionEvents;
387387
}
388388
if (!action.modifiers) {
389389
action.modifiers = {};
390390
}
391-
if ($.type(action.modifiers) === 'string') {
391+
if (typeof action.modifiers === 'string') {
392392
var actionModifiers = {};
393393
actionModifiers[action.modifiers] = true;
394394
action.modifiers = actionModifiers;
@@ -912,6 +912,17 @@ var util = {
912912
return leftSide.slice(0, leftSide.length - 1).concat(rightSide);
913913
},
914914

915+
/**
916+
* Replicate jQuery 3's isNumeric function.
917+
*
918+
* @param {*} n Value to test
919+
* @returns {boolean} True if the value is a finite number or a numeric
920+
* string.
921+
*/
922+
isNumeric: function (n) {
923+
return (typeof n === 'number' || typeof n === 'string') && !isNaN(n - parseFloat(n));
924+
},
925+
915926
/**
916927
* Given an array, return the minimum and maximum values within the array.
917928
* If a numeric value is specified for one or the other, return that instead.
@@ -930,7 +941,7 @@ var util = {
930941
* @memberof geo.util
931942
*/
932943
getMinMaxValues: function (values, min, max, limit) {
933-
if (values.length && (limit || !$.isNumeric(min) || !$.isNumeric(max))) {
944+
if (values.length && (limit || !util.isNumeric(min) || !util.isNumeric(max))) {
934945
var minValue = values[0],
935946
maxValue = values[0],
936947
value, i;
@@ -939,10 +950,10 @@ var util = {
939950
if (value < minValue) { minValue = value; }
940951
if (value > maxValue) { maxValue = value; }
941952
}
942-
if (!$.isNumeric(min) || (limit && minValue > min)) {
953+
if (!util.isNumeric(min) || (limit && minValue > min)) {
943954
min = minValue;
944955
}
945-
if (!$.isNumeric(max) || (limit && maxValue < max)) {
956+
if (!util.isNumeric(max) || (limit && maxValue < max)) {
946957
max = maxValue;
947958
}
948959
}

tests/headed-cases/examples.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ describe('examples', function () {
8888
} catch (err) { }
8989
if (idle) {
9090
exampleWindow.clearInterval(interval);
91-
if (!ex$.isFunction(idle)) {
91+
if (typeof idle !== 'function') {
9292
idle = idle.then || idle.done;
9393
}
9494
idle(function () {

tests/test-utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ module.exports.getQuery = function () {
272272
* It should be done if the webgl renderer was mocked before it is restored.
273273
*/
274274
function destroyMap() {
275-
if ($('#map').data('data-geojs-map') && $.isFunction($('#map').data('data-geojs-map').exit)) {
275+
if ($('#map').data('data-geojs-map') && typeof $('#map').data('data-geojs-map').exit === 'function') {
276276
$('#map').data('data-geojs-map').exit();
277277
}
278278
$('#map').remove();

tests/tutorials.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe('tutorials', function () {
6060
var defer = tut$.Deferred();
6161
deferreds.push(defer);
6262
var idle = targetWindow.eval(idleFunc);
63-
if (!tut$.isFunction(idle)) {
63+
if (typeof idle !== 'function') {
6464
idle = idle.then || idle.done;
6565
}
6666
idle(function () {

webpack.base.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ module.exports = {
3131
},
3232
resolve: {
3333
alias: {
34-
jquery: 'jquery/dist/jquery',
3534
proj4: 'proj4/lib',
3635
hammerjs: '@egjs/hammerjs/dist/hammer.js',
3736
mousetrap: 'mousetrap/mousetrap.js'
@@ -58,6 +57,7 @@ module.exports = {
5857
/node_modules\/@velipso\/polybool/,
5958
/node_modules\/color-name/,
6059
/node_modules\/earcut/,
60+
/node_modules\/jquery/,
6161
/node_modules\/kdbush/,
6262
/node_modules\/proj4/,
6363
/node_modules\/wkt-parser/

0 commit comments

Comments
 (0)