Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
Created August 2, 2021 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nolanlawson/ae9ff8d7b9a2aa70b85c0f955e6c90b3 to your computer and use it in GitHub Desktop.
Save nolanlawson/ae9ff8d7b9a2aa70b85c0f955e6c90b3 to your computer and use it in GitHub Desktop.
Repro property set before custom elemet 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