Skip to content

Commit

Permalink
remove jquery
Browse files Browse the repository at this point in the history
  • Loading branch information
oyejorge committed Oct 26, 2023
1 parent 7bd39ea commit dceef1c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
1 change: 0 additions & 1 deletion .config/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
14 changes: 7 additions & 7 deletions test/tests/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

Expand Down Expand Up @@ -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);
});
});

Expand Down Expand Up @@ -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);
});

Expand Down
8 changes: 4 additions & 4 deletions test/tests/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
20 changes: 12 additions & 8 deletions test/tests/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();

});
Expand Down Expand Up @@ -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('<select> (custom jquery render)', function() {
describe('<select> (custom render)', function() {
var test;

beforeEach(function() {
Expand All @@ -471,7 +471,11 @@
'</select>', {
render: {
option: function(item, escape) {
return $('<div class="option custom-option">').text(item.text);

let div = document.createElement('div');
div.className = 'option custom-option';
div.innerText = item.text;
return div
}
}
});
Expand All @@ -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);
});
Expand Down

0 comments on commit dceef1c

Please sign in to comment.