Template scripts are not encapsulated within the shadow root

Comments

1 comment

  • Official comment
    Liva Deksne

    Hi Salman,

    You are correct, shadow root encapsulates only HTML and CSS. In order to encapsulate javascript, you need to do your logic only on specific selectors. Let's say you want to query an element on the campaign, therefore you can use DY variable ${dyVariationId} and add it to the element as a class name. This generates a unique ID based on the variation. Then in the Javascript you can specifically query this class name and interact with the element as needed.

    For example,

    HTML:

    <div class="test${dyVariationId}">

    <div>Some text</div>

    </div>

    Javascript:

    const elementNode = document.querySelector('.test${dyvariationId}');

    // interact with the specific element afterward...

     

    Please if any more information is needed for your specific campaign, reach out to your Technical Account Manager.

     

    Regards,

    Liva

    Technical Account Manager Team Lead

    Comment actions Permalink

Please sign in to leave a comment.