From 33211eefdfb27eff7ba21886e16f2efdc0efa3e6 Mon Sep 17 00:00:00 2001 From: Alessandro Chitolina Date: Fri, 15 Sep 2017 16:07:24 +0200 Subject: Rewritten modal without jquery (#23955) * Trigger jquery events if available in event handler * Rewritten modal without jquery --- js/tests/unit/modal.js | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) (limited to 'js/tests/unit/modal.js') diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js index 9b7fb0aa6..cfac27bba 100644 --- a/js/tests/unit/modal.js +++ b/js/tests/unit/modal.js @@ -209,9 +209,12 @@ $(function () { .on('shown.bs.modal', function () { assert.ok($('#modal-test').length, 'modal inserted into dom') assert.ok($('#modal-test').is(':visible'), 'modal visible') - $div.trigger($.Event('keydown', { - which: 27 - })) + + var evt = document.createEvent('HTMLEvents') + evt.initEvent('keydown', true, true) + evt.which = 27 + + $div[0].dispatchEvent(evt) setTimeout(function () { assert.ok(!$('#modal-test').is(':visible'), 'modal hidden') @@ -308,15 +311,19 @@ $(function () { .one('hidden.bs.modal', function () { // After one open-close cycle assert.ok(!$('#modal-test').is(':visible'), 'modal hidden') - $(this) - .one('shown.bs.modal', function () { - $('#close').trigger('click') - }) - .one('hidden.bs.modal', function () { - assert.ok(!$('#modal-test').is(':visible'), 'modal hidden') - done() - }) - .bootstrapModal('show') + + var $this = $(this) + setTimeout(function () { + $this + .one('shown.bs.modal', function () { + $('#close').trigger('click') + }) + .one('hidden.bs.modal', function () { + assert.ok(!$('#modal-test').is(':visible'), 'modal hidden') + done() + }) + .bootstrapModal('show') + }, 0) }) .bootstrapModal('show') }) @@ -595,7 +602,6 @@ $(function () { QUnit.test('should not follow link in area tag', function (assert) { assert.expect(2) - var done = assert.async() $('') .appendTo('#qunit-fixture') @@ -603,16 +609,19 @@ $(function () { $('