Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace innerHTML with Trusted Types friendly ways #821

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Aug 23, 2023

  1. replace innerHTML with TT friendly ways

    This will enable usage in [Trusted Types](https://developer.mozilla.org/en-US/docs/Web/API/Trusted_Types_API)
    context.
    As Element.innerHTML is considered to be dangerous injection sink, its usage is denied
    when `Content-Security-Policy` enforces `require-trusted-types-for 'script'` directive.
    
    E.g. it throws something like this from `clearElement` function:
    ```
    TypeError: Failed to set the 'innerHTML' property on 'Element': This document requires 'TrustedHTML' assignment.
        at D.clearElement (xyz.js:733:62)
        at D.start (xyz.js:710:176)
    ```
    
    [textContent](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent#differences_from_innerhtml) in MDN.
    [replaceChildren](https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceChildren) has [~91% coverage](https://caniuse.com/mdn-api_element_replacechildren)
    Snurppa committed Aug 23, 2023
    Configuration menu
    Copy the full SHA
    c332881 View commit details
    Browse the repository at this point in the history