Skip to content

Instantly share code, notes, and snippets.

@KonnorRogers
Created August 23, 2024 05:11
Show Gist options
  • Save KonnorRogers/3e91b8db091895778ddb9dfd6df1a46a to your computer and use it in GitHub Desktop.
Save KonnorRogers/3e91b8db091895778ddb9dfd6df1a46a to your computer and use it in GitHub Desktop.
the joy of SSR
<!-- Case 1 -->
<my-input value="foo">
<template shadowrootmode="open">
<input value="foo">
</template>
</my-input>
<script>
myInput.value = "bar"
customElements.define("my-input", MyInput)
// => <my-input value="foo">
// myInput.value => "bar"
</script>
<!-- Case 2 -->
<my-input value="foo">
<template shadowrootmode="open">
<input value="foo">
</template>
</my-input>
<script>
myInput.value = null
customElements.define("my-input", MyInput)
// => <my-input value="foo">
// myInput.value => null
</script>
<!-- Case 3 -->
<my-input value="foo">
<template shadowrootmode="open">
<input value="foo">
</template>
</my-input>
<script>
myInput.value = "bar"
myInput.defaultValue = "baz"
customElements.define("my-input", MyInput)
// => <my-input value="baz">
// myInput.value => "bar"
</script>
Solution: not sure yet. TLDR: tracking dirty values prior to the component connecting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment