I have this component, andI would like to do some manipulations on its children elements in ways that are not feasible in a state-driven way. So I would like to use a statement and a querySelector
in it. But how can I scope it to the element? There are multiple instances of the component in the page, so a class or id is not possible. How can I achieve this?
Here's a simplified code:
<script> export let value = '' export let readonly = true $: if (value && !readonly){ // selects the first element in the document, not the one from this instance const nd = document.querySelector('.forminput') // Do something with nd }</script><textarea bind:value wrap="soft" rows="1" class="forminput"></textarea>