From: Andrew Luca Date: Thu, 18 Oct 2018 22:26:11 +0000 (+0300) Subject: test(Modal): check if modal is disposed X-Git-Tag: v4.2.0~172 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd2851938a5a5764adac008613825fb2daca0326;p=thirdparty%2Fbootstrap.git test(Modal): check if modal is disposed --- diff --git a/js/src/modal.js b/js/src/modal.js index 704b022472..0004fe8bbe 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -196,9 +196,17 @@ class Modal { } dispose() { - $.removeData(this._element, DATA_KEY) + [window, this._element, this._dialog] + .forEach((htmlElement) => $(htmlElement).off(EVENT_KEY)) + + /** + * `document` has 2 events `Event.FOCUSIN` and `Event.CLICK_DATA_API` + * Do not move `document` in `htmlElements` array + * It will remove `Event.CLICK_DATA_API` event that should remain + */ + $(document).off(Event.FOCUSIN) - $(window, document, this._element, this._backdrop).off(EVENT_KEY) + $.removeData(this._element, DATA_KEY) this._config = null this._element = null diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js index 7c8299109e..4c857105b8 100644 --- a/js/tests/unit/modal.js +++ b/js/tests/unit/modal.js @@ -697,4 +697,37 @@ $(function () { beginTimestamp = Date.now() }) + + QUnit.test('should dispose modal', function (assert) { + assert.expect(3) + var done = assert.async() + + var $modal = $([ + '