Does ctx.root point to the component or the document root?

  • Edwin Paul

    2 months ago

    Hey, does ctx.root.querySelector search within the component itself or from the document root? I usually generate dynamic IDs, but I’m hoping there’s a cleaner way.
  • Jacob Kofoed

    2 months ago

    It searches from the document root. The only difference from using document.querySelector is if the component is being used as a web-component, in which case ctx.root would return the ShadowRoot.
    👍1
  • /attachments/1553009081663496293/1553011425050361856/image.png

    Edwin Paul

    2 months ago

    I was confused by the AI's response
    image.png
    😵‍💫1

Stop scrolling. Start building.

toddle is a visual web app builder that rivals custom code — but accessible to your entire team!

Try toddle — it's free!

© Copyright 2024 toddle. All rights reserved.