| | |
| | | if (this.global) { |
| | | if (this.errorEventListener) { |
| | | this.global.removeEventListener('error', this.errorEventListener); |
| | | } // Dispose "document" to prevent "load" event from triggering. |
| | | } |
| | | |
| | | this.global.close(); // Dispose "document" to prevent "load" event from triggering. |
| | | // Note that this.global.close() will trigger the CustomElement::disconnectedCallback |
| | | // Do not reset the document before CustomElement disconnectedCallback function has finished running, |
| | | // document should be accessible within disconnectedCallback. |
| | | |
| | | Object.defineProperty(this.global, 'document', { |
| | | value: null |
| | | }); |
| | | this.global.close(); |
| | | } |
| | | |
| | | this.errorEventListener = null; // @ts-expect-error |