diff --git a/package-lock.json b/package-lock.json index ec295934e0..942f066d9c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "gl-mat4": "^1.2.0", "gl-vec3": "^1.1.3", "gl-vec4": "^1.0.1", - "jquery": "^3.6.0", + "jquery": "^4.0.0", "kdbush": "^4.0.0", "mousetrap": "^1.6.5", "proj4": "^2.7.5" @@ -8338,9 +8338,9 @@ } }, "node_modules/jquery": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.7.1.tgz", - "integrity": "sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-4.0.0.tgz", + "integrity": "sha512-TXCHVR3Lb6TZdtw1l3RTLf8RBWVGexdxL6AC8/e0xZKEpBflBsjh9/8LXw+dkNFuOyW9B7iB3O1sP7hS0Kiacg==", "license": "MIT" }, "node_modules/js-stringify": { diff --git a/package.json b/package.json index eb129d8c0b..8e1ea9d51f 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "gl-mat4": "^1.2.0", "gl-vec3": "^1.1.3", "gl-vec4": "^1.0.1", - "jquery": "^3.6.0", + "jquery": "^4.0.0", "kdbush": "^4.0.0", "mousetrap": "^1.6.5", "proj4": "^2.7.5" diff --git a/src/map.js b/src/map.js index 74262d5366..070a814532 100644 --- a/src/map.js +++ b/src/map.js @@ -1004,7 +1004,7 @@ var map = function (arg) { throw new Error('Map require DIV node'); } - if (m_node.data('data-geojs-map') && $.isFunction(m_node.data('data-geojs-map').exit)) { + if (m_node.data('data-geojs-map') && typeof m_node.data('data-geojs-map').exit === 'function') { m_node.data('data-geojs-map').exit(); } m_node.addClass('geojs-map'); diff --git a/src/tileLayer.js b/src/tileLayer.js index b4b7dc1d83..e55110fedd 100644 --- a/src/tileLayer.js +++ b/src/tileLayer.js @@ -205,7 +205,7 @@ var tileLayer = function (arg) { // (math.ceil(min(w, h) / (ts*2**l)) + 1) for l in range(ml)]) arg.cacheSize = arg.keepLower ? 600 : 200; } - if ($.type(arg.subdomains) === 'string') { + if (typeof arg.subdomains === 'string') { arg.subdomains = arg.subdomains.split(''); } /* We used to call the url option baseUrl. If a baseUrl is specified, use @@ -219,7 +219,7 @@ var tileLayer = function (arg) { } /* Save the original url so that we can return it if asked */ arg.originalUrl = arg.url; - if ($.type(arg.url) === 'string') { + if (typeof arg.url === 'string') { arg.url = m_tileUrlFromTemplate(arg.url); } @@ -1636,7 +1636,7 @@ var tileLayer = function (arg) { return m_this; } m_this._options.originalUrl = url; - if ($.type(url) === 'string') { + if (typeof url === 'string') { url = m_tileUrlFromTemplate(url); } m_this._options.url = url; @@ -1657,7 +1657,7 @@ var tileLayer = function (arg) { return m_this._options.subdomains; } if (subdomains) { - if ($.type(subdomains) === 'string') { + if (typeof subdomains === 'string') { if (subdomains.indexOf(',') >= 0) { subdomains = subdomains.split(','); } else { diff --git a/src/util/common.js b/src/util/common.js index 93fb8c80ac..18e795147b 100644 --- a/src/util/common.js +++ b/src/util/common.js @@ -380,7 +380,7 @@ var util = { var action, i; for (i = 0; i < actions.length; i += 1) { action = actions[i]; - if ($.type(action.input) === 'string') { + if (typeof action.input === 'string') { var actionEvents = {}; actionEvents[action.input] = true; action.input = actionEvents; @@ -388,7 +388,7 @@ var util = { if (!action.modifiers) { action.modifiers = {}; } - if ($.type(action.modifiers) === 'string') { + if (typeof action.modifiers === 'string') { var actionModifiers = {}; actionModifiers[action.modifiers] = true; action.modifiers = actionModifiers; @@ -912,6 +912,17 @@ var util = { return leftSide.slice(0, leftSide.length - 1).concat(rightSide); }, + /** + * Replicate jQuery 3's isNumeric function. + * + * @param {*} n Value to test + * @returns {boolean} True if the value is a finite number or a numeric + * string. + */ + isNumeric: function (n) { + return (typeof n === 'number' || typeof n === 'string') && !isNaN(n - parseFloat(n)); + }, + /** * Given an array, return the minimum and maximum values within the array. * If a numeric value is specified for one or the other, return that instead. @@ -930,7 +941,7 @@ var util = { * @memberof geo.util */ getMinMaxValues: function (values, min, max, limit) { - if (values.length && (limit || !$.isNumeric(min) || !$.isNumeric(max))) { + if (values.length && (limit || !util.isNumeric(min) || !util.isNumeric(max))) { var minValue = values[0], maxValue = values[0], value, i; @@ -939,10 +950,10 @@ var util = { if (value < minValue) { minValue = value; } if (value > maxValue) { maxValue = value; } } - if (!$.isNumeric(min) || (limit && minValue > min)) { + if (!util.isNumeric(min) || (limit && minValue > min)) { min = minValue; } - if (!$.isNumeric(max) || (limit && maxValue < max)) { + if (!util.isNumeric(max) || (limit && maxValue < max)) { max = maxValue; } } diff --git a/tests/headed-cases/examples.js b/tests/headed-cases/examples.js index 6e90a9462b..02ff183b2a 100644 --- a/tests/headed-cases/examples.js +++ b/tests/headed-cases/examples.js @@ -88,7 +88,7 @@ describe('examples', function () { } catch (err) { } if (idle) { exampleWindow.clearInterval(interval); - if (!ex$.isFunction(idle)) { + if (typeof idle !== 'function') { idle = idle.then || idle.done; } idle(function () { diff --git a/tests/test-utils.js b/tests/test-utils.js index 3c40229b11..9c2bf7d0db 100644 --- a/tests/test-utils.js +++ b/tests/test-utils.js @@ -272,7 +272,7 @@ module.exports.getQuery = function () { * It should be done if the webgl renderer was mocked before it is restored. */ function destroyMap() { - if ($('#map').data('data-geojs-map') && $.isFunction($('#map').data('data-geojs-map').exit)) { + if ($('#map').data('data-geojs-map') && typeof $('#map').data('data-geojs-map').exit === 'function') { $('#map').data('data-geojs-map').exit(); } $('#map').remove(); diff --git a/tests/tutorials.js b/tests/tutorials.js index 67cfc5db30..8be2ff9f46 100644 --- a/tests/tutorials.js +++ b/tests/tutorials.js @@ -60,7 +60,7 @@ describe('tutorials', function () { var defer = tut$.Deferred(); deferreds.push(defer); var idle = targetWindow.eval(idleFunc); - if (!tut$.isFunction(idle)) { + if (typeof idle !== 'function') { idle = idle.then || idle.done; } idle(function () { diff --git a/webpack.base.config.js b/webpack.base.config.js index 8e2b586f6e..3e04e13bf9 100644 --- a/webpack.base.config.js +++ b/webpack.base.config.js @@ -31,7 +31,6 @@ module.exports = { }, resolve: { alias: { - jquery: 'jquery/dist/jquery', proj4: 'proj4/lib', hammerjs: '@egjs/hammerjs/dist/hammer.js', mousetrap: 'mousetrap/mousetrap.js' @@ -58,6 +57,7 @@ module.exports = { /node_modules\/@velipso\/polybool/, /node_modules\/color-name/, /node_modules\/earcut/, + /node_modules\/jquery/, /node_modules\/kdbush/, /node_modules\/proj4/, /node_modules\/wkt-parser/