File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,11 @@ class Backdrop {
116
116
117
117
EventHandler . off ( this . _element , EVENT_MOUSEDOWN )
118
118
119
- this . _getElement ( ) . parentNode . removeChild ( this . _element )
119
+ const { parentNode } = this . _getElement ( )
120
+ if ( parentNode ) {
121
+ parentNode . removeChild ( this . _element )
122
+ }
123
+
120
124
this . _isAppended = false
121
125
}
122
126
Original file line number Diff line number Diff line change @@ -129,6 +129,25 @@ describe('Backdrop', () => {
129
129
} )
130
130
} )
131
131
132
+ it ( 'should not error if the backdrop no longer has a parent' , done => {
133
+ const instance = new Backdrop ( {
134
+ isVisible : true ,
135
+ isAnimated : true
136
+ } )
137
+ const getElements = ( ) => document . querySelectorAll ( CLASS_BACKDROP )
138
+
139
+ instance . show ( ( ) => {
140
+ instance . hide ( ( ) => {
141
+ expect ( getElements ( ) . length ) . toEqual ( 0 )
142
+
143
+ // replace the fixture, which was just wiped out
144
+ fixtureEl = getFixture ( )
145
+ done ( )
146
+ } )
147
+ document . body . innerHTML = 'changed'
148
+ } )
149
+ } )
150
+
132
151
describe ( 'click callback' , ( ) => {
133
152
it ( 'it should execute callback on click' , done => {
134
153
const spy = jasmine . createSpy ( 'spy' )
You can’t perform that action at this time.
0 commit comments