From dceef1ca7dff29058e2d96d1bf819a6b1c4f4b00 Mon Sep 17 00:00:00 2001 From: Josh Schmidt Date: Thu, 26 Oct 2023 17:14:51 -0600 Subject: [PATCH] remove jquery --- .config/karma.conf.js | 1 - package.json | 3 --- test/tests/api.js | 14 +++++++------- test/tests/events.js | 8 ++++---- test/tests/setup.js | 20 ++++++++++++-------- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.config/karma.conf.js b/.config/karma.conf.js index fe392b1e..399813bf 100644 --- a/.config/karma.conf.js +++ b/.config/karma.conf.js @@ -156,7 +156,6 @@ module.exports = function(config) { 'build/js/tom-select.complete.js', 'node_modules/syn/dist/global/syn.js', - 'node_modules/jquery/dist/jquery.js', 'build/css/tom-select.default.css', 'test/support/*.js', config.test_one ? 'test/tests/interaction.js' : 'test/tests/**/*.js', diff --git a/package.json b/package.json index 831f4651..fec6036e 100644 --- a/package.json +++ b/package.json @@ -44,8 +44,6 @@ "@rollup/plugin-babel": "^6.0.3", "@rollup/plugin-node-resolve": "^15.0.1", "@rollup/plugin-terser": "^0.4.4", - "@types/jquery": "^3.5.24", - "@types/jqueryui": "^1.12.19", "autoprefixer": "^10.4.16", "bootstrap": "npm:bootstrap@4", "bootstrap-sass": "^3.4.3", @@ -64,7 +62,6 @@ "grunt-shell": "^4.0.0", "husky": "^8.0.3", "icon-blender": "^1.0.0-beta.4", - "jquery": "^3.7.1", "jsdom": "^22.1.0", "karma": "^6.4.2", "karma-browserstack-launcher": "^1.6.0", diff --git a/test/tests/api.js b/test/tests/api.js index c73186f0..e6a4bef1 100644 --- a/test/tests/api.js +++ b/test/tests/api.js @@ -21,7 +21,7 @@ }); it_n('should add "disabled" attribute on inputs', function() { expect(test.instance.input.disabled).to.be.equal(true); - expect( $(test.instance.control_input).is(':disabled')).to.be.equal(true); + expect( test.instance.control_input.disabled ).to.be.equal(true); }); }); @@ -68,7 +68,7 @@ }); it_n('should remove "disabled" attribute on inputs', function() { expect(test.instance.input.disabled).to.be.equal(false); - expect( $(test.instance.control_input).is(':disabled')).to.be.equal(false); + expect( test.instance.control_input.disabled ).to.be.equal(false); }); }); @@ -405,16 +405,16 @@ }); it_n('should update DOM (1)', function() { test.instance.addItem('c'); - expect( $(test.instance.control).find('[data-value=c]').length).to.be.equal(1); + expect( test.instance.control.querySelectorAll('[data-value=c]').length).to.be.equal(1); test.instance.addItem('$1'); var found = false; - $(test.instance.control).children().each(function() { - if (this.getAttribute('data-value') === '$1') { + for( const child of test.instance.control.children ){ + if( child.getAttribute('data-value') === '$1' ){ found = true; - return false; + break; } - }); + } expect(found).to.be.equal(true); }); diff --git a/test/tests/events.js b/test/tests/events.js index 9f05d85c..22f15234 100644 --- a/test/tests/events.js +++ b/test/tests/events.js @@ -79,7 +79,7 @@ describe('Events', function() { syn.click(test.instance.control).delay(0, function() { syn - .click($('[data-value="a"]', $(test.instance.dropdown))) + .click( test.instance.dropdown.querySelector('[data-value="a"]') ) .delay(0, function() { expect(test.counter).to.be.equal(0); done(); @@ -97,7 +97,7 @@ describe('Events', function() { syn.click(test.instance.control).delay(0, function() { syn - .click($('[data-value="a"]', $(test.instance.dropdown))) + .click( test.instance.dropdown.querySelector('[data-value="a"]') ) .delay(0, function() { expect(test.counter).to.be.equal(0); done(); @@ -118,7 +118,7 @@ describe('Events', function() { syn.click(test.instance.control).delay(0, function() { syn - .click($('[data-value="c"]', $(test.instance.dropdown))) + .click( test.instance.dropdown.querySelector('[data-value="c"]') ) .delay(0, function() { expect(test.counter).to.be.equal(0); done(); @@ -148,7 +148,7 @@ describe('Events', function() { syn.click(test.instance.control).delay(0, function() { syn - .click($('[data-value="a"]', test.instance.dropdown)) + .click( test.instance.dropdown.querySelector('[data-value="a"]') ) .delay(0, function() { expect(counter).to.be.equal(0); done(); diff --git a/test/tests/setup.js b/test/tests/setup.js index c1308288..f9ac9384 100644 --- a/test/tests/setup.js +++ b/test/tests/setup.js @@ -326,8 +326,8 @@ test.instance.refreshOptions(true); - $(test.instance.dropdown).find('[data-value]').each(function(i, el) { - order_actual.push($(el).attr('data-value')); + test.instance.dropdown.querySelectorAll('[data-value]').forEach(function(el) { + order_actual.push( el.dataset.value ); }); expect(order_actual).to.eql(order_expected); @@ -342,8 +342,8 @@ test.instance.refreshOptions(true); - expect($(test.instance.dropdown).find('.option')).to.has.length(2); - expect($(test.instance.dropdown).find('[data-selectable]')).to.has.length(1); + expect( test.instance.dropdown.querySelectorAll('.option') ).to.has.length(2); + expect( test.instance.dropdown.querySelectorAll('[data-selectable]') ).to.has.length(1); done(); }); @@ -455,13 +455,13 @@ test.instance.focus(); window.setTimeout(function() { - expect($(test.instance.dropdown_content).find('.custom-option').length).to.be.equal(1); + expect( test.instance.dropdown_content.querySelectorAll('.custom-option').length ).to.be.equal(1); done(); }, 5); }); }); - describe(' (custom render)', function() { var test; beforeEach(function() { @@ -471,7 +471,11 @@ '', { render: { option: function(item, escape) { - return $('
').text(item.text); + + let div = document.createElement('div'); + div.className = 'option custom-option'; + div.innerText = item.text; + return div } } }); @@ -481,7 +485,7 @@ test.instance.focus(); window.setTimeout(function() { - expect($(test.instance.dropdown_content).find('.custom-option').length).to.be.equal(1); + expect( test.instance.dropdown_content.querySelectorAll('.custom-option').length).to.be.equal(1); done(); }, 5); });