Last active
November 29, 2024 16:32
-
-
Save nolanlawson/38766a5d15a338adf7265c9317919577 to your computer and use it in GitHub Desktop.
test isConnected during move in jsdom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jsdom = require("jsdom") | |
const { JSDOM } = jsdom | |
const { window } = new JSDOM(``) | |
const { document } = window | |
window.customElements.define('x-foo', class extends window.HTMLElement { | |
connectedCallback() { console.log('cC') } | |
disconnectedCallback() { console.log('dC, this.isConnected?', this.isConnected) } | |
}) | |
const foo = document.createElement('x-foo') | |
document.body.appendChild(foo) | |
const div = document.createElement('div') | |
document.body.appendChild(div) | |
document.body.removeChild(foo) | |
div.appendChild(foo) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment