From a2b5901efc6de12bb828f8dda118ddccbcd545cf Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Fri, 21 May 2021 18:16:05 -0400 Subject: Fix bug where backdrop calls method on null if it is already removed from the body (#34014) Co-authored-by: Rohit Sharma --- js/tests/unit/util/backdrop.spec.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'js/tests/unit') diff --git a/js/tests/unit/util/backdrop.spec.js b/js/tests/unit/util/backdrop.spec.js index ae342b092..02dea5a25 100644 --- a/js/tests/unit/util/backdrop.spec.js +++ b/js/tests/unit/util/backdrop.spec.js @@ -129,6 +129,25 @@ describe('Backdrop', () => { }) }) + it('should not error if the backdrop no longer has a parent', done => { + const instance = new Backdrop({ + isVisible: true, + isAnimated: true + }) + const getElements = () => document.querySelectorAll(CLASS_BACKDROP) + + instance.show(() => { + instance.hide(() => { + expect(getElements().length).toEqual(0) + + // replace the fixture, which was just wiped out + fixtureEl = getFixture() + done() + }) + document.body.innerHTML = 'changed' + }) + }) + describe('click callback', () => { it('it should execute callback on click', done => { const spy = jasmine.createSpy('spy') -- cgit v1.2.3