Skip to content

Instantly share code, notes, and snippets.

@MiggieNRG
Created January 2, 2022 00:57
Show Gist options
  • Save MiggieNRG/c7c85eeea0aa462da245ee1b1c2f83d2 to your computer and use it in GitHub Desktop.
Save MiggieNRG/c7c85eeea0aa462da245ee1b1c2f83d2 to your computer and use it in GitHub Desktop.
Repro property set before custom element upgrade
customElements.define('hello-world', class extends HTMLElement {
constructor() {
super()
this.innerHTML = '<div>Hello world!</div>'
}
set mode (mode) {
this.querySelector('div')
.setAttribute('style', mode === 'light'
? 'background: white; color: black;'
: 'background: black; color: white;'
)
}
})
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Repro property set before custom element upgrade</title>
</head>
<body>
<h1>Repro property set before custom element upgrade</h1>
<hello-world></hello-world>
<script src="./hello.js" type="module"></script>
<script>
document.querySelector('hello-world').mode = 'dark'
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment