PricingBlog

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

  • sanedealer-1553009081663496293

    Edwin Paul

    1 day 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.
  • jacobkofoed-1553009524003184711

    Jacob Kofoed

    1 day 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
  • sanedealer-1553011426048614400

    Edwin Paul

    1 day ago

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