Skip to content

Commit dceef1c

Browse files
committed
remove jquery
1 parent 7bd39ea commit dceef1c

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

.config/karma.conf.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ module.exports = function(config) {
156156

157157
'build/js/tom-select.complete.js',
158158
'node_modules/syn/dist/global/syn.js',
159-
'node_modules/jquery/dist/jquery.js',
160159
'build/css/tom-select.default.css',
161160
'test/support/*.js',
162161
config.test_one ? 'test/tests/interaction.js' : 'test/tests/**/*.js',

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
"@rollup/plugin-babel": "^6.0.3",
4545
"@rollup/plugin-node-resolve": "^15.0.1",
4646
"@rollup/plugin-terser": "^0.4.4",
47-
"@types/jquery": "^3.5.24",
48-
"@types/jqueryui": "^1.12.19",
4947
"autoprefixer": "^10.4.16",
5048
"bootstrap": "npm:bootstrap@4",
5149
"bootstrap-sass": "^3.4.3",
@@ -64,7 +62,6 @@
6462
"grunt-shell": "^4.0.0",
6563
"husky": "^8.0.3",
6664
"icon-blender": "^1.0.0-beta.4",
67-
"jquery": "^3.7.1",
6865
"jsdom": "^22.1.0",
6966
"karma": "^6.4.2",
7067
"karma-browserstack-launcher": "^1.6.0",

test/tests/api.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
});
2222
it_n('should add "disabled" attribute on inputs', function() {
2323
expect(test.instance.input.disabled).to.be.equal(true);
24-
expect( $(test.instance.control_input).is(':disabled')).to.be.equal(true);
24+
expect( test.instance.control_input.disabled ).to.be.equal(true);
2525
});
2626
});
2727

@@ -68,7 +68,7 @@
6868
});
6969
it_n('should remove "disabled" attribute on inputs', function() {
7070
expect(test.instance.input.disabled).to.be.equal(false);
71-
expect( $(test.instance.control_input).is(':disabled')).to.be.equal(false);
71+
expect( test.instance.control_input.disabled ).to.be.equal(false);
7272
});
7373
});
7474

@@ -405,16 +405,16 @@
405405
});
406406
it_n('should update DOM (1)', function() {
407407
test.instance.addItem('c');
408-
expect( $(test.instance.control).find('[data-value=c]').length).to.be.equal(1);
408+
expect( test.instance.control.querySelectorAll('[data-value=c]').length).to.be.equal(1);
409409

410410
test.instance.addItem('$1');
411411
var found = false;
412-
$(test.instance.control).children().each(function() {
413-
if (this.getAttribute('data-value') === '$1') {
412+
for( const child of test.instance.control.children ){
413+
if( child.getAttribute('data-value') === '$1' ){
414414
found = true;
415-
return false;
415+
break;
416416
}
417-
});
417+
}
418418
expect(found).to.be.equal(true);
419419
});
420420

test/tests/events.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ describe('Events', function() {
7979

8080
syn.click(test.instance.control).delay(0, function() {
8181
syn
82-
.click($('[data-value="a"]', $(test.instance.dropdown)))
82+
.click( test.instance.dropdown.querySelector('[data-value="a"]') )
8383
.delay(0, function() {
8484
expect(test.counter).to.be.equal(0);
8585
done();
@@ -97,7 +97,7 @@ describe('Events', function() {
9797

9898
syn.click(test.instance.control).delay(0, function() {
9999
syn
100-
.click($('[data-value="a"]', $(test.instance.dropdown)))
100+
.click( test.instance.dropdown.querySelector('[data-value="a"]') )
101101
.delay(0, function() {
102102
expect(test.counter).to.be.equal(0);
103103
done();
@@ -118,7 +118,7 @@ describe('Events', function() {
118118

119119
syn.click(test.instance.control).delay(0, function() {
120120
syn
121-
.click($('[data-value="c"]', $(test.instance.dropdown)))
121+
.click( test.instance.dropdown.querySelector('[data-value="c"]') )
122122
.delay(0, function() {
123123
expect(test.counter).to.be.equal(0);
124124
done();
@@ -148,7 +148,7 @@ describe('Events', function() {
148148

149149
syn.click(test.instance.control).delay(0, function() {
150150
syn
151-
.click($('[data-value="a"]', test.instance.dropdown))
151+
.click( test.instance.dropdown.querySelector('[data-value="a"]') )
152152
.delay(0, function() {
153153
expect(counter).to.be.equal(0);
154154
done();

test/tests/setup.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@
326326

327327
test.instance.refreshOptions(true);
328328

329-
$(test.instance.dropdown).find('[data-value]').each(function(i, el) {
330-
order_actual.push($(el).attr('data-value'));
329+
test.instance.dropdown.querySelectorAll('[data-value]').forEach(function(el) {
330+
order_actual.push( el.dataset.value );
331331
});
332332

333333
expect(order_actual).to.eql(order_expected);
@@ -342,8 +342,8 @@
342342

343343
test.instance.refreshOptions(true);
344344

345-
expect($(test.instance.dropdown).find('.option')).to.has.length(2);
346-
expect($(test.instance.dropdown).find('[data-selectable]')).to.has.length(1);
345+
expect( test.instance.dropdown.querySelectorAll('.option') ).to.has.length(2);
346+
expect( test.instance.dropdown.querySelectorAll('[data-selectable]') ).to.has.length(1);
347347
done();
348348

349349
});
@@ -455,13 +455,13 @@
455455
test.instance.focus();
456456

457457
window.setTimeout(function() {
458-
expect($(test.instance.dropdown_content).find('.custom-option').length).to.be.equal(1);
458+
expect( test.instance.dropdown_content.querySelectorAll('.custom-option').length ).to.be.equal(1);
459459
done();
460460
}, 5);
461461
});
462462
});
463463

464-
describe('<select> (custom jquery render)', function() {
464+
describe('<select> (custom render)', function() {
465465
var test;
466466

467467
beforeEach(function() {
@@ -471,7 +471,11 @@
471471
'</select>', {
472472
render: {
473473
option: function(item, escape) {
474-
return $('<div class="option custom-option">').text(item.text);
474+
475+
let div = document.createElement('div');
476+
div.className = 'option custom-option';
477+
div.innerText = item.text;
478+
return div
475479
}
476480
}
477481
});
@@ -481,7 +485,7 @@
481485
test.instance.focus();
482486

483487
window.setTimeout(function() {
484-
expect($(test.instance.dropdown_content).find('.custom-option').length).to.be.equal(1);
488+
expect( test.instance.dropdown_content.querySelectorAll('.custom-option').length).to.be.equal(1);
485489
done();
486490
}, 5);
487491
});

0 commit comments

Comments
 (0)