From 7679abf098342cd94fbe8d8e3d22c2fcf03f9858 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Wed, 7 Feb 2024 22:05:49 +0100 Subject: [PATCH] add support for jQuery 4.0 --- __tests__/terminal.spec.js | 16 ++++++++-------- js/jquery.terminal-src.js | 20 ++++++++++---------- js/less.js | 4 ++-- package-lock.json | 28 ++++++++++++++-------------- package.json | 4 ++-- 5 files changed, 36 insertions(+), 36 deletions(-) diff --git a/__tests__/terminal.spec.js b/__tests__/terminal.spec.js index b453c4df..8caa6d81 100644 --- a/__tests__/terminal.spec.js +++ b/__tests__/terminal.spec.js @@ -3082,7 +3082,7 @@ describe('Terminal plugin', function() { }); expect(term.find('.cmd-prompt').text()).toEqual('>>>'); }); - it('should render funtion that return promise', async () => { + it('should render function that return promise', async () => { var term = $('
').terminal($.noop, { prompt: function() { return Promise.resolve('>>>'); @@ -3091,7 +3091,7 @@ describe('Terminal plugin', function() { await delay(10); expect(term.find('.cmd-prompt').text()).toEqual('>>>'); }); - it('should render funtion that call callback', () => { + it('should render function that call callback', () => { var term = $('
').terminal($.noop, { prompt: function(fn) { fn('>>>'); @@ -4081,7 +4081,7 @@ describe('Terminal plugin', function() { $.ajax = function(obj) { function done() { if (!canceled) { - if ($.isFunction(obj.success)) { + if (typeof obj.success === 'function') { obj.success(response, 'OK', { getResponseHeader: function(header) { if (header == 'Content-Type') { @@ -4104,7 +4104,7 @@ describe('Terminal plugin', function() { }; $(document).trigger("ajaxSend", [ jqXHR, obj ] ); try { - if ($.isFunction(obj.beforeSend)) { + if (typeof obj.beforeSend === 'function') { obj.beforeSend({}, obj); } if (options.async) { @@ -4142,7 +4142,7 @@ describe('Terminal plugin', function() { var proc = { name: key }; - if ($.isFunction(object[key])) { + if (typeof object[key] === 'function') { var re = /function[^\(]+\(([^\)]+)\)/; var m = object[key].toString().match(re); if (m) { @@ -4153,7 +4153,7 @@ describe('Terminal plugin', function() { } $.ajax = function(obj) { function done() { - if ($.isFunction(obj.success)) { + if (typeof obj.success === 'function') { obj.success(resp, 'OK', { getResponseHeader: function(header) { if (header == 'Content-Type') { @@ -4192,7 +4192,7 @@ describe('Terminal plugin', function() { var error = null; var ret = null; try { - if ($.isFunction(object[req.method])) { + if (typeof object[req.method] === 'function') { ret = object[req.method].apply(null, req.params); } else { ret = null; @@ -5566,7 +5566,7 @@ describe('Terminal plugin', function() { var term = $('
').appendTo('body').terminal(interpreter); expect(term.commands()).toEqual(interpreter); term.push('/test'); - expect($.isFunction(term.commands())).toEqual(true); + expect(typeof term.commands() === 'function').toEqual(true); term.destroy().remove(); }); }); diff --git a/js/jquery.terminal-src.js b/js/jquery.terminal-src.js index b2ef1ad0..b62ffbcb 100644 --- a/js/jquery.terminal-src.js +++ b/js/jquery.terminal-src.js @@ -283,13 +283,13 @@ clone_object: function(object) { var tmp = {}; if (typeof object === 'object') { - if ($.isArray(object)) { + if (Array.isArray(object)) { return this.clone_array(object); } else if (object === null) { return object; } else { for (var key in object) { - if ($.isArray(object[key])) { + if (Array.isArray(object[key])) { tmp[key] = this.clone_array(object[key]); } else if (typeof object[key] === 'object') { tmp[key] = this.clone_object(object[key]); @@ -625,7 +625,7 @@ if (value === undefined || value === null) { return null; } - var result = this.regex.exec(jQuery.trim(value.toString())); + var result = this.regex.exec(value.toString().trim()); if (result[2]) { var num = parseInt(result[1], 10); var mult = this.powers[result[2]] || 1; @@ -637,7 +637,7 @@ add: function(element, interval, label, fn, times, belay) { var counter = 0; - if (jQuery.isFunction(label)) { + if (typeof label === 'function') { if (!times) { times = fn; } @@ -7107,7 +7107,7 @@ }; } function validJSONRPC(response) { - return $.isNumeric(response.id) && + return typeof response.id === 'number' && (typeof response.result !== 'undefined' || typeof response.error !== 'undefined'); } @@ -8102,7 +8102,7 @@ object = { interpreter: make_basic_json_rpc(user_intrp, login) }; - if ($.isArray(settings.completion)) { + if (Array.isArray(settings.completion)) { object.completion = settings.completion; } finalize(object); @@ -9410,7 +9410,7 @@ // will be used internaly since users know // when login success (they decide when // it happen by calling the callback - - // this funtion) + // this function) if (is_function(next)) { next(); } @@ -9611,7 +9611,7 @@ } else { save_state.push(self.export_view()); } - if (!$.isArray(hash_commands)) { + if (!Array.isArray(hash_commands)) { hash_commands = []; } if (command !== undefined && !ignore_hash) { @@ -9665,7 +9665,7 @@ } var d = exec_settings.deferred; cmd_ready(function ready() { - if ($.isArray(command)) { + if (Array.isArray(command)) { (function recur() { var cmd = command.shift(); if (cmd) { @@ -11237,7 +11237,7 @@ // result is object with interpreter and completion properties interpreters.push($.extend({}, ret, push_settings)); if (push_settings.completion === true) { - if ($.isArray(ret.completion)) { + if (Array.isArray(ret.completion)) { interpreters.top().completion = ret.completion; } else if (!ret.completion) { interpreters.top().completion = false; diff --git a/js/less.js b/js/less.js index 1aad73ca..8a107f61 100644 --- a/js/less.js +++ b/js/less.js @@ -218,7 +218,7 @@ term.removeClass('terminal-less'); $output.css('height', ''); var exit = options.exit || options.onExit; - if ($.isFunction(exit)) { + if (typeof exit === 'function') { exit(); } } @@ -299,7 +299,7 @@ }); } } - if ($.isFunction(text)) { + if (typeof text === 'function') { text(cols, run); } else { run(text); diff --git a/package-lock.json b/package-lock.json index b28d7732..b30152bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,10 +10,10 @@ "license": "MIT", "dependencies": { "@jcubic/lily": "^0.3.0", - "@types/jquery": "^3.5.14", + "@types/jquery": "^3.5.29", "ansidec": "^0.3.4", "iconv-lite": "^0.6.3", - "jquery": "^3.6.0", + "jquery": "^4.0.0-beta", "prismjs": "^1.27.0", "wcwidth": "^1.0.1" }, @@ -1162,9 +1162,9 @@ } }, "node_modules/@types/jquery": { - "version": "3.5.14", - "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.5.14.tgz", - "integrity": "sha512-X1gtMRMbziVQkErhTQmSe2jFwwENA/Zr+PprCkF63vFq+Yt5PZ4AlKqgmeNlwgn7dhsXEK888eIW2520EpC+xg==", + "version": "3.5.29", + "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.5.29.tgz", + "integrity": "sha512-oXQQC9X9MOPRrMhPHHOsXqeQDnWeCDT3PelUIg/Oy8FAbzSZtFHRjc7IpbfFVmpLtJ+UOoywpRsuO5Jxjybyeg==", "dependencies": { "@types/sizzle": "*" } @@ -3899,9 +3899,9 @@ } }, "node_modules/jquery": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.0.tgz", - "integrity": "sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw==" + "version": "4.0.0-beta", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-4.0.0-beta.tgz", + "integrity": "sha512-F/LxAJ1KuoIfS5j6T5R57YceLJfXjwBl5hJ9za2itWyCy24YqU5R/DzRf76RrpeHfpJgQyqwnPbUQbjSfoEBcQ==" }, "node_modules/js-tokens": { "version": "4.0.0", @@ -7067,9 +7067,9 @@ } }, "@types/jquery": { - "version": "3.5.14", - "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.5.14.tgz", - "integrity": "sha512-X1gtMRMbziVQkErhTQmSe2jFwwENA/Zr+PprCkF63vFq+Yt5PZ4AlKqgmeNlwgn7dhsXEK888eIW2520EpC+xg==", + "version": "3.5.29", + "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.5.29.tgz", + "integrity": "sha512-oXQQC9X9MOPRrMhPHHOsXqeQDnWeCDT3PelUIg/Oy8FAbzSZtFHRjc7IpbfFVmpLtJ+UOoywpRsuO5Jxjybyeg==", "requires": { "@types/sizzle": "*" } @@ -9171,9 +9171,9 @@ } }, "jquery": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.0.tgz", - "integrity": "sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw==" + "version": "4.0.0-beta", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-4.0.0-beta.tgz", + "integrity": "sha512-F/LxAJ1KuoIfS5j6T5R57YceLJfXjwBl5hJ9za2itWyCy24YqU5R/DzRf76RrpeHfpJgQyqwnPbUQbjSfoEBcQ==" }, "js-tokens": { "version": "4.0.0", diff --git a/package.json b/package.json index 6c862bfe..ead62f91 100644 --- a/package.json +++ b/package.json @@ -367,10 +367,10 @@ }, "dependencies": { "@jcubic/lily": "^0.3.0", - "@types/jquery": "^3.5.14", + "@types/jquery": "^3.5.29", "ansidec": "^0.3.4", "iconv-lite": "^0.6.3", - "jquery": "^3.6.0", + "jquery": "^4.0.0-beta", "prismjs": "^1.27.0", "wcwidth": "^1.0.1" },