diff --git a/js/tests/unit/alert.js b/js/tests/unit/alert.js index d5437a7376..17d7be01eb 100644 --- a/js/tests/unit/alert.js +++ b/js/tests/unit/alert.js @@ -45,7 +45,7 @@ $(function () { var $alert = $(alertHTML).bootstrapAlert().appendTo($('#qunit-fixture')) var closeBtn = $alert.find('.close')[0] - EventHandler.trigger(closeBtn, 'click') + closeBtn.dispatchEvent(new Event('click')) assert.strictEqual($alert.hasClass('show'), false, 'remove .show class on .close click') }) @@ -60,13 +60,13 @@ $(function () { assert.notEqual($('#qunit-fixture').find('.alert').length, 0, 'element added to dom') - EventHandler.on($alert[0], 'closed.bs.alert', function () { + $alert[0].addEventListener('closed.bs.alert', function () { assert.strictEqual($('#qunit-fixture').find('.alert').length, 0, 'element removed from dom') done() }) var closeBtn = $alert.find('.close')[0] - EventHandler.trigger(closeBtn, 'click') + closeBtn.dispatchEvent(new Event('click')) }) QUnit.test('should not fire closed when close is prevented', function (assert) { @@ -75,12 +75,12 @@ $(function () { var $alert = $('
') $alert.appendTo('#qunit-fixture') - EventHandler.on($alert[0], 'close.bs.alert', function (e) { + $alert[0].addEventListener('close.bs.alert', function (e) { e.preventDefault() assert.ok(true, 'close event fired') done() }) - EventHandler.on($alert[0], 'closed.bs.alert', function () { + $alert[0].addEventListener('closed.bs.alert', function () { assert.ok(false, 'closed event fired') }) @@ -95,7 +95,7 @@ $(function () { var $alert = $el.bootstrapAlert() var alertInstance = Alert._getInstance($alert[0]) - $alert.one('closed.bs.alert', function () { + $alert[0].addEventListener('closed.bs.alert', function () { assert.ok('alert closed') done() }) diff --git a/js/tests/unit/button.js b/js/tests/unit/button.js index 50b531f6f0..e116730c2e 100644 --- a/js/tests/unit/button.js +++ b/js/tests/unit/button.js @@ -125,25 +125,26 @@ $(function () { var $btn1 = $group.children().eq(0) var $btn2 = $group.children().eq(1) + var inputBtn2 = $btn2.find('input')[0] assert.ok($btn1.hasClass('active'), 'btn1 has active class') assert.ok($btn1.find('input').prop('checked'), 'btn1 is checked') assert.ok(!$btn2.hasClass('active'), 'btn2 does not have active class') - assert.ok(!Manipulator.isChecked($btn2.find('input')[0]), 'btn2 is not checked') + assert.ok(!(inputBtn2.bsChecked || inputBtn2.checked), 'btn2 is not checked') - EventHandler.trigger($btn2.find('input')[0], 'click') + inputBtn2.dispatchEvent(new Event('click')) assert.ok(!$btn1.hasClass('active'), 'btn1 does not have active class') assert.ok(!$btn1.find('input').prop('checked'), 'btn1 is not checked') assert.ok($btn2.hasClass('active'), 'btn2 has active class') - assert.ok(Manipulator.isChecked($btn2.find('input')[0]), 'btn2 is checked') + assert.ok(inputBtn2.bsChecked || inputBtn2.checked, 'btn2 is checked') - EventHandler.trigger($btn2.find('input')[0], 'click') // clicking an already checked radio should not un-check it + inputBtn2.dispatchEvent(new Event('click')) // clicking an already checked radio should not un-check it assert.ok(!$btn1.hasClass('active'), 'btn1 does not have active class') assert.ok(!$btn1.find('input').prop('checked'), 'btn1 is not checked') assert.ok($btn2.hasClass('active'), 'btn2 has active class') - assert.ok(Manipulator.isChecked($btn2.find('input')[0]), 'btn2 is checked') + assert.ok(inputBtn2.bsChecked || inputBtn2.checked, 'btn2 is checked') }) QUnit.test('should only toggle selectable inputs', function (assert) { diff --git a/js/tests/unit/carousel.js b/js/tests/unit/carousel.js index f89dfcf969..6533454a69 100644 --- a/js/tests/unit/carousel.js +++ b/js/tests/unit/carousel.js @@ -116,12 +116,12 @@ $(function () { var $carousel = $('' var $carousel = $(carouselHTML) + var done = assert.async() var getActiveId = function () { return $carousel.find('.carousel-item.active').attr('id') } - var done = assert.async() - - EventHandler.one($carousel[0], 'slid.bs.carousel', function () { - assert.strictEqual(getActiveId(), 'two', 'carousel slid from 1st to 2nd slide') - - EventHandler.one($carousel[0], 'slid.bs.carousel', function () { - assert.strictEqual(getActiveId(), 'three', 'carousel slid from 2nd to 3rd slide') - - EventHandler.one($carousel[0], 'slid.bs.carousel', function () { - assert.strictEqual(getActiveId(), 'one', 'carousel wrapped around and slid from 3rd to 1st slide') - done() - }) + $carousel[0].addEventListener('slid.bs.carousel', function () { + var activeId = getActiveId() + if (activeId === 'two') { + assert.strictEqual(activeId, 'two', 'carousel slid from 1st to 2nd slide') $carousel.bootstrapCarousel('next') - }) - $carousel.bootstrapCarousel('next') + return + } + + if (activeId === 'three') { + assert.strictEqual(activeId, 'three', 'carousel slid from 2nd to 3rd slide') + $carousel.bootstrapCarousel('next') + return + } + + if (activeId === 'one') { + assert.strictEqual(activeId, 'one', 'carousel wrapped around and slid from 3rd to 1st slide') + done() + } }) $carousel.bootstrapCarousel('next') }) @@ -843,7 +859,7 @@ $(function () { var done = assert.async() - EventHandler.one($carousel[0], 'slid.bs.carousel', function () { + $carousel[0].addEventListener('slid.bs.carousel', function () { assert.strictEqual($carousel.find('.carousel-item.active').attr('id'), 'three', 'carousel wrapped around and slid from 1st to 3rd slide') done() }) @@ -872,27 +888,26 @@ $(function () { '' + '' + '
' - var $carousel = $(carouselHTML) + var $carousel = $(carouselHTML).appendTo('#qunit-fixture') var getActiveId = function () { return $carousel.find('.carousel-item.active').attr('id') } var done = assert.async() + $carousel[0].addEventListener('slid.bs.carousel', function () { + var activeId = getActiveId() + if (activeId === 'two') { + assert.strictEqual(activeId, 'two', 'carousel slid from 1st to 2nd slide') + $carousel.bootstrapCarousel('next') + return + } - EventHandler.one($carousel[0], 'slid.bs.carousel', function () { - assert.strictEqual(getActiveId(), 'two', 'carousel slid from 1st to 2nd slide') - - EventHandler.one($carousel[0], 'slid.bs.carousel', function () { - assert.strictEqual(getActiveId(), 'three', 'carousel slid from 2nd to 3rd slide') - - EventHandler.one($carousel[0], 'slid.bs.carousel', function () { - assert.ok(false, 'carousel slid when it should not have slid') - }) + if (activeId === 'three') { + assert.strictEqual(activeId, 'three', 'carousel slid from 2nd to 3rd slide') $carousel.bootstrapCarousel('next') assert.strictEqual(getActiveId(), 'three', 'carousel did not wrap around and stayed on 3rd slide') done() - }) - $carousel.bootstrapCarousel('next') + } }) $carousel.bootstrapCarousel('next') }) @@ -921,7 +936,7 @@ $(function () { '' var $carousel = $(carouselHTML) - EventHandler.one($carousel[0], 'slid.bs.carousel', function () { + $carousel[0].addEventListener('slid.bs.carousel', function () { assert.ok(false, 'carousel slid when it should not have slid') }) $carousel.bootstrapCarousel('prev') diff --git a/js/tests/unit/collapse.js b/js/tests/unit/collapse.js index 66cf6af961..bb11645b2b 100644 --- a/js/tests/unit/collapse.js +++ b/js/tests/unit/collapse.js @@ -73,7 +73,7 @@ $(function () { assert.ok(!/height/i.test($el2.attr('style')), 'has height reset') done() }) - EventHandler.trigger($target[0], 'click') + $target[0].dispatchEvent(new Event('click')) }) QUnit.test('should collapse only the first collapse', function (assert) { @@ -167,7 +167,7 @@ $(function () { done() }) - EventHandler.trigger($target[0], 'click') + $target[0].dispatchEvent(new Event('click')) }) QUnit.test('should add "collapsed" class to target when collapse is hidden', function (assert) { @@ -183,7 +183,7 @@ $(function () { done() }) - EventHandler.trigger($target[0], 'click') + $target[0].dispatchEvent(new Event('click')) }) QUnit.test('should remove "collapsed" class from all triggers targeting the collapse when the collapse is shown', function (assert) { @@ -201,7 +201,7 @@ $(function () { done() }) - EventHandler.trigger($target[0], 'click') + $target[0].dispatchEvent(new Event('click')) }) QUnit.test('should add "collapsed" class to all triggers targeting the collapse when the collapse is hidden', function (assert) { @@ -219,7 +219,7 @@ $(function () { done() }) - EventHandler.trigger($target[0], 'click') + $target[0].dispatchEvent(new Event('click')) }) QUnit.test('should not close a collapse when initialized with "show" option if already shown', function (assert) { @@ -311,7 +311,7 @@ $(function () { done() }) - EventHandler.trigger($target3[0], 'click') + $target3[0].dispatchEvent(new Event('click')) }) QUnit.test('should allow dots in data-parent', function (assert) { @@ -345,7 +345,7 @@ $(function () { done() }) - EventHandler.trigger($target3[0], 'click') + $target3[0].dispatchEvent(new Event('click')) }) QUnit.test('should set aria-expanded="true" on trigger/control when collapse is shown', function (assert) { @@ -361,7 +361,7 @@ $(function () { done() }) - EventHandler.trigger($target[0], 'click') + $target[0].dispatchEvent(new Event('click')) }) QUnit.test('should set aria-expanded="false" on trigger/control when collapse is hidden', function (assert) { @@ -377,7 +377,7 @@ $(function () { done() }) - EventHandler.trigger($target[0], 'click') + $target[0].dispatchEvent(new Event('click')) }) QUnit.test('should set aria-expanded="true" on all triggers targeting the collapse when the collapse is shown', function (assert) { @@ -395,7 +395,7 @@ $(function () { done() }) - EventHandler.trigger($target[0], 'click') + $target[0].dispatchEvent(new Event('click')) }) QUnit.test('should set aria-expanded="false" on all triggers targeting the collapse when the collapse is hidden', function (assert) { @@ -413,7 +413,7 @@ $(function () { done() }) - EventHandler.trigger($target[0], 'click') + $target[0].dispatchEvent(new Event('click')) }) QUnit.test('should change aria-expanded from active accordion trigger/control to "false" and set the trigger/control for the newly active one to "true"', function (assert) { @@ -447,7 +447,7 @@ $(function () { done() }) - EventHandler.trigger($target3[0], 'click') + $target3[0].dispatchEvent(new Event('click')) }) QUnit.test('should not fire show event if show is prevented because other element is still transitioning', function (assert) { @@ -472,12 +472,12 @@ $(function () { var $target2 = $('').appendTo($groups.eq(1)) var $body2 = $('
').appendTo($groups.eq(1)) - EventHandler.trigger($target2[0], 'click') + $target2[0].dispatchEvent(new Event('click')) $body2.toggleClass('show collapsing') Collapse._getInstance($body2[0])._isTransitioning = true - EventHandler.trigger($target1[0], 'click') + $target1[0].dispatchEvent(new Event('click')) setTimeout(function () { assert.ok(!showFired, 'show event did not fire') @@ -542,9 +542,9 @@ $(function () { assert.ok($collapseTwo.hasClass('show'), '#collapseTwo is shown') done() }) - EventHandler.trigger($triggerTwo[0], 'click') + $triggerTwo[0].dispatchEvent(new Event('click')) }) - EventHandler.trigger($trigger[0], 'click') + $trigger[0].dispatchEvent(new Event('click')) }) QUnit.test('should allow accordion to contain nested elements', function (assert) { @@ -582,9 +582,9 @@ $(function () { assert.ok($collapseTwo.hasClass('show'), '#collapseTwo is shown') done() }) - EventHandler.trigger($triggerTwo[0], 'click') + $triggerTwo[0].dispatchEvent(new Event('click')) }) - EventHandler.trigger($trigger[0], 'click') + $trigger[0].dispatchEvent(new Event('click')) }) QUnit.test('should allow accordion to target multiple elements', function (assert) { @@ -616,7 +616,7 @@ $(function () { assert.ok($collapseOneTwo.hasClass('show'), '#collapseOneTwo is shown') assert.ok(!$collapseTwoOne.hasClass('show'), '#collapseTwoOne is not shown') assert.ok(!$collapseTwoTwo.hasClass('show'), '#collapseTwoTwo is not shown') - EventHandler.trigger($triggerTwo[0], 'click') + $triggerTwo[0].dispatchEvent(new Event('click')) } function secondTest() { @@ -659,7 +659,7 @@ $(function () { } }) - EventHandler.trigger($trigger[0], 'click') + $trigger[0].dispatchEvent(new Event('click')) }) QUnit.test('should collapse accordion children but not nested accordion children', function (assert) { @@ -690,26 +690,33 @@ $(function () { var $collapseTwo = $('#collapseTwo') var $nestedCollapseOne = $('#nestedCollapseOne') - EventHandler.one($collapseOne[0], 'shown.bs.collapse', function () { + function handlerCollapseOne() { assert.ok($collapseOne.hasClass('show'), '#collapseOne is shown') assert.ok(!$collapseTwo.hasClass('show'), '#collapseTwo is not shown') assert.ok(!$('#nestedCollapseOne').hasClass('show'), '#nestedCollapseOne is not shown') - EventHandler.one($nestedCollapseOne[0], 'shown.bs.collapse', function () { - assert.ok($collapseOne.hasClass('show'), '#collapseOne is shown') - assert.ok(!$collapseTwo.hasClass('show'), '#collapseTwo is not shown') + $nestedCollapseOne[0].addEventListener('shown.bs.collapse', handlerNestedCollapseOne) + $nestedTrigger[0].dispatchEvent(new Event('click')) + $collapseOne[0].removeEventListener('shown.bs.collapse', handlerCollapseOne) + } + + function handlerNestedCollapseOne() { + assert.ok($collapseOne.hasClass('show'), '#collapseOne is shown') + assert.ok(!$collapseTwo.hasClass('show'), '#collapseTwo is not shown') + assert.ok($nestedCollapseOne.hasClass('show'), '#nestedCollapseOne is shown') + + $collapseTwo[0].addEventListener('shown.bs.collapse', function () { + assert.ok(!$collapseOne.hasClass('show'), '#collapseOne is not shown') + assert.ok($collapseTwo.hasClass('show'), '#collapseTwo is shown') assert.ok($nestedCollapseOne.hasClass('show'), '#nestedCollapseOne is shown') - EventHandler.one($collapseTwo[0], 'shown.bs.collapse', function () { - assert.ok(!$collapseOne.hasClass('show'), '#collapseOne is not shown') - assert.ok($collapseTwo.hasClass('show'), '#collapseTwo is shown') - assert.ok($nestedCollapseOne.hasClass('show'), '#nestedCollapseOne is shown') - done() - }) - EventHandler.trigger($triggerTwo[0], 'click') + done() }) - EventHandler.trigger($nestedTrigger[0], 'click') - }) - EventHandler.trigger($trigger[0], 'click') + $triggerTwo[0].dispatchEvent(new Event('click')) + $nestedCollapseOne[0].removeEventListener('shown.bs.collapse', handlerNestedCollapseOne) + } + + $collapseOne[0].addEventListener('shown.bs.collapse', handlerCollapseOne) + $trigger[0].dispatchEvent(new Event('click')) }) QUnit.test('should not prevent event for input', function (assert) { @@ -718,7 +725,7 @@ $(function () { var $target = $('').appendTo('#qunit-fixture') var $collapse = $('
').appendTo('#qunit-fixture') - EventHandler.one($collapse[0], 'shown.bs.collapse', function () { + $collapse[0].addEventListener('shown.bs.collapse', function () { assert.ok($collapse.hasClass('show')) assert.ok($target.attr('aria-expanded') === 'true') assert.ok($target.prop('checked')) @@ -753,11 +760,11 @@ $(function () { assert.ok($trigger3.hasClass('collapsed'), 'trigger3 has collapsed class') done() }) - EventHandler.trigger($trigger1[0], 'click') + $trigger1[0].dispatchEvent(new Event('click')) }) - EventHandler.trigger($trigger2[0], 'click') + $trigger2[0].dispatchEvent(new Event('click')) }) - EventHandler.trigger($trigger3[0], 'click') + $trigger3[0].dispatchEvent(new Event('click')) }) QUnit.test('should set aria-expanded="true" to triggers targeting shown collaspe and aria-expanded="false" only when all the targeted collapses are shown', function (assert) { @@ -785,11 +792,11 @@ $(function () { assert.strictEqual($trigger3.attr('aria-expanded'), 'false', 'aria-expanded on trigger3 is "false"') done() }) - EventHandler.trigger($trigger1[0], 'click') + $trigger1[0].dispatchEvent(new Event('click')) }) - EventHandler.trigger($trigger2[0], 'click') + $trigger2[0].dispatchEvent(new Event('click')) }) - EventHandler.trigger($trigger3[0], 'click') + $trigger3[0].dispatchEvent(new Event('click')) }) QUnit.test('should not prevent interactions inside the collapse element', function (assert) { @@ -803,7 +810,7 @@ $(function () { '
' var $collapse = $(htmlCollapse).appendTo('#qunit-fixture') - EventHandler.one($collapse[0], 'shown.bs.collapse', function () { + $collapse[0].addEventListener('shown.bs.collapse', function () { assert.ok($target.prop('checked'), '$trigger is checked') var $testCheckbox = $('#testCheckbox') $testCheckbox.trigger($.Event('click')) diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js index c89d5abb29..44fe761ad8 100644 --- a/js/tests/unit/dropdown.js +++ b/js/tests/unit/dropdown.js @@ -90,7 +90,7 @@ $(function () { assert.ok(!$dropdown.parent('.dropdown').hasClass('position-static'), '"position-static" class not added') done() }) - EventHandler.trigger($dropdown[0], 'click') + $dropdown[0].dispatchEvent(new Event('click')) }) QUnit.test('should add class position-static to dropdown if boundary not scrollParent', function (assert) { @@ -112,7 +112,7 @@ $(function () { assert.ok($dropdown.parent('.dropdown').hasClass('position-static'), '"position-static" class added') done() }) - EventHandler.trigger($dropdown[0], 'click') + $dropdown[0].dispatchEvent(new Event('click')) }) QUnit.test('should set aria-expanded="true" on target when dropdown menu is shown', function (assert) { @@ -136,11 +136,11 @@ $(function () { var dropdownParent = $dropdown.parent('.dropdown')[0] - EventHandler.on(dropdownParent, 'shown.bs.dropdown', function () { + dropdownParent.addEventListener('shown.bs.dropdown', function () { assert.strictEqual($dropdown.attr('aria-expanded'), 'true', 'aria-expanded is set to string "true" on click') done() }) - EventHandler.trigger($dropdown[0], 'click') + $dropdown[0].dispatchEvent(new Event('click')) }) QUnit.test('should set aria-expanded="false" on target when dropdown menu is hidden', function (assert) { @@ -164,13 +164,13 @@ $(function () { var dropdownParent = $dropdown.parent('.dropdown')[0] - EventHandler.one(dropdownParent, 'hidden.bs.dropdown', function () { + dropdownParent.addEventListener('hidden.bs.dropdown', function () { assert.strictEqual($dropdown.attr('aria-expanded'), 'false', 'aria-expanded is set to string "false" on hide') done() }) - EventHandler.trigger($dropdown[0], 'click') - EventHandler.trigger(document.body, 'click') + $dropdown[0].dispatchEvent(new Event('click')) + document.body.click() }) QUnit.test('should not open dropdown if target is disabled via class', function (assert) { @@ -221,7 +221,7 @@ $(function () { assert.ok($dropdown.parent('.dropdown').hasClass('show'), '"show" class added on click') done() }) - EventHandler.trigger($dropdown[0], 'click') + $dropdown[0].dispatchEvent(new Event('click')) }) QUnit.test('should remove "show" class if body is clicked', function (assert) { @@ -253,7 +253,7 @@ $(function () { done() }) - EventHandler.trigger($dropdown[0], 'click') + $dropdown[0].dispatchEvent(new Event('click')) }) QUnit.test('should remove "show" class if tabbing outside of menu', function (assert) { @@ -279,16 +279,16 @@ $(function () { .on('shown.bs.dropdown', function () { assert.ok($dropdown.parent('.dropdown').hasClass('show'), '"show" class added on click') - EventHandler.trigger(document.body, 'keyup', { - which: 9 // Tab - }) + var keyup9 = new Event('keyup') + keyup9.which = 9 // Tab + document.dispatchEvent(keyup9) }) .on('hidden.bs.dropdown', function () { assert.ok(!$dropdown.parent('.dropdown').hasClass('show'), '"show" class removed') done() }) - EventHandler.trigger($dropdown[0], 'click') + $dropdown[0].dispatchEvent(new Event('click')) }) QUnit.test('should remove "show" class if body is clicked, with multiple dropdowns', function (assert) { @@ -322,7 +322,7 @@ $(function () { $(document.body).trigger('click') }).on('hidden.bs.dropdown', function () { assert.strictEqual($('#qunit-fixture .dropdown-menu.show').length, 0, '"show" class removed') - EventHandler.trigger($last[0], 'click') + $last[0].dispatchEvent(new Event('click')) }) $last.parent('.btn-group') @@ -334,7 +334,7 @@ $(function () { assert.strictEqual($('#qunit-fixture .dropdown-menu.show').length, 0, '"show" class removed') done() }) - EventHandler.trigger($first[0], 'click') + $first[0].dispatchEvent(new Event('click')) }) QUnit.test('should remove "show" class if body if tabbing outside of menu, with multiple dropdowns', function (assert) { @@ -365,26 +365,26 @@ $(function () { .on('shown.bs.dropdown', function () { assert.strictEqual($first.parents('.show').length, 1, '"show" class added on click') assert.strictEqual($('#qunit-fixture .dropdown-menu.show').length, 1, 'only one dropdown is shown') - EventHandler.trigger(document.body, 'keyup', { - which: 9 // Tab - }) + var keyup = new Event('keyup') + keyup.which = 9 // Tab + document.dispatchEvent(keyup) }).on('hidden.bs.dropdown', function () { assert.strictEqual($('#qunit-fixture .dropdown-menu.show').length, 0, '"show" class removed') - EventHandler.trigger($last[0], 'click') + $last[0].dispatchEvent(new Event('click')) }) $last.parent('.btn-group') .on('shown.bs.dropdown', function () { assert.strictEqual($last.parent('.show').length, 1, '"show" class added on click') assert.strictEqual($('#qunit-fixture .dropdown-menu.show').length, 1, 'only one dropdown is shown') - EventHandler.trigger(document.body, 'keyup', { - which: 9 // Tab - }) + var keyup = new Event('keyup') + keyup.which = 9 // Tab + document.dispatchEvent(keyup) }).on('hidden.bs.dropdown', function () { assert.strictEqual($('#qunit-fixture .dropdown-menu.show').length, 0, '"show" class removed') done() }) - EventHandler.trigger($first[0], 'click') + $first[0].dispatchEvent(new Event('click')) }) QUnit.test('should fire show and hide event', function (assert) { @@ -417,8 +417,8 @@ $(function () { done() }) - EventHandler.trigger($dropdown[0], 'click') - EventHandler.trigger(document.body, 'click') + $dropdown[0].dispatchEvent(new Event('click')) + document.body.click() }) QUnit.test('should fire shown and hidden event', function (assert) { @@ -451,8 +451,8 @@ $(function () { done() }) - EventHandler.trigger($dropdown[0], 'click') - EventHandler.trigger(document.body, 'click') + $dropdown[0].dispatchEvent(new Event('click')) + document.body.click() }) QUnit.test('should fire shown and hidden event with a relatedTarget', function (assert) { @@ -484,7 +484,7 @@ $(function () { $(document.body).trigger('click') }) - EventHandler.trigger($dropdown[0], 'click') + $dropdown[0].dispatchEvent(new Event('click')) }) QUnit.test('should fire hide and hidden event with a clickEvent', function (assert) { @@ -598,7 +598,7 @@ $(function () { done() }) - EventHandler.trigger($dropdown[0], 'click') + $dropdown[0].dispatchEvent(new Event('click')) }) QUnit.test('should skip disabled element when using keyboard navigation', function (assert) { @@ -633,7 +633,7 @@ $(function () { assert.ok(!$(document.activeElement).is(':disabled'), ':disabled is not focused') done() }) - EventHandler.trigger($dropdown[0], 'click') + $dropdown[0].dispatchEvent(new Event('click')) }) QUnit.test('should focus next/previous element when using keyboard navigation', function (assert) { @@ -658,23 +658,21 @@ $(function () { .on('shown.bs.dropdown', function () { assert.ok(true, 'shown was fired') - EventHandler.trigger($dropdown[0], 'keydown', { - which: 40 - }) + var keydown40 = new Event('keydown') + keydown40.which = 40 + $dropdown[0].dispatchEvent(keydown40) assert.ok($(document.activeElement).is($('#item1')), 'item1 is focused') - EventHandler.trigger(document.activeElement, 'keydown', { - which: 40 - }) + document.activeElement.dispatchEvent(keydown40) assert.ok($(document.activeElement).is($('#item2')), 'item2 is focused') - EventHandler.trigger(document.activeElement, 'keydown', { - which: 38 - }) + var keydown38 = new Event('keydown') + keydown38.which = 38 + document.activeElement.dispatchEvent(keydown38) assert.ok($(document.activeElement).is($('#item1')), 'item1 is focused') done() }) - EventHandler.trigger($dropdown[0], 'click') + $dropdown[0].dispatchEvent(new Event('click')) }) QUnit.test('should not close the dropdown if the user clicks on a text field', function (assert) { @@ -701,9 +699,9 @@ $(function () { .parent('.dropdown') .on('shown.bs.dropdown', function () { assert.ok($dropdown.parent('.dropdown').hasClass('show'), 'dropdown menu is shown') - EventHandler.trigger($textfield[0], 'click') + $textfield[0].dispatchEvent(new Event('click')) }) - EventHandler.trigger($dropdown[0], 'click') + $dropdown[0].dispatchEvent(new Event('click')) }) QUnit.test('should not close the dropdown if the user clicks on a textarea', function (assert) { @@ -730,9 +728,9 @@ $(function () { .parent('.dropdown') .on('shown.bs.dropdown', function () { assert.ok($dropdown.parent('.dropdown').hasClass('show'), 'dropdown menu is shown') - EventHandler.trigger($textarea[0], 'click') + $textarea[0].dispatchEvent(new Event('click')) }) - EventHandler.trigger($dropdown[0], 'click') + $dropdown[0].dispatchEvent(new Event('click')) }) QUnit.test('Dropdown should not use Popper.js in navbar', function (assert) { @@ -761,7 +759,7 @@ $(function () { assert.ok(typeof $dropdownMenu.attr('style') === 'undefined', 'No inline style applied by Popper.js') done() }) - EventHandler.trigger($triggerDropdown[0], 'click') + $triggerDropdown[0].dispatchEvent(new Event('click')) }) QUnit.test('should ignore keyboard events for s and