Cleans up the overlay from the DOM.
()
| 276 | |
| 277 | /** Cleans up the overlay from the DOM. */ |
| 278 | dispose(): void { |
| 279 | if (this._disposed) { |
| 280 | return; |
| 281 | } |
| 282 | |
| 283 | const isAttached = this.hasAttached(); |
| 284 | |
| 285 | if (this._positionStrategy) { |
| 286 | this._positionStrategy.dispose(); |
| 287 | } |
| 288 | |
| 289 | this._disposeScrollStrategy(); |
| 290 | this._backdropRef?.dispose(); |
| 291 | this._locationChanges?.(); |
| 292 | this._keyboardDispatcher.remove(this); |
| 293 | this._portalOutlet.dispose(); |
| 294 | this._attachments.complete(); |
| 295 | this._backdropClick.complete(); |
| 296 | this._keydownEvents.complete(); |
| 297 | this._outsidePointerEvents.complete(); |
| 298 | this._outsideClickDispatcher.remove(this); |
| 299 | this._host?.remove(); |
| 300 | this._afterNextRenderRef?.destroy(); |
| 301 | this._previousHostParent = this._pane = this._host = this._backdropRef = null!; |
| 302 | |
| 303 | if (isAttached) { |
| 304 | this._detachments.next(); |
| 305 | } |
| 306 | |
| 307 | this._detachments.complete(); |
| 308 | this._completeDetachContent(); |
| 309 | this._disposed = true; |
| 310 | |
| 311 | untracked(() => { |
| 312 | attachedOverlaysInternal.update(prev => prev.filter(o => o !== this)); |
| 313 | }); |
| 314 | } |
| 315 | |
| 316 | /** Whether the overlay has attached content. */ |
| 317 | hasAttached(): boolean { |
no test coverage detected