Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
Created November 5, 2021 18:40
Show Gist options
  • Save nolanlawson/cbc40307e15f99be6e084ac0fffb59be to your computer and use it in GitHub Desktop.
Save nolanlawson/cbc40307e15f99be6e084ac0fffb59be to your computer and use it in GitHub Desktop.
Bare ::part(foo) selector
<!doctype html>
<html lang=en>
<head>
<title>Bare ::part(foo) selector</title>
</head>
<body>
<h1>Bare ::part(foo) selector</h1>
<custom-component></custom-component>
<body>
<script type=module>
class CustomComponent extends HTMLElement {
constructor() {
super()
this.attachShadow({ mode: 'open' }).innerHTML = `
<style>
::part(foo) {
color: blue;
}
</style>
<span part="foo">I should NOT be blue</span>
`
}
}
customElements.define('custom-component', CustomComponent)
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment