Skip to content

Conditional dangerouslySetInnerHTML triggers Trusted Types violation #4934

@lukewarlow

Description

@lukewarlow
  • Check if updating to the latest Preact version resolves the issue

Describe the bug
If you conditionally apply dangerouslySetInnerHTML, Preact internal code leads to a TrustedTypes violation.

To Reproduce

If possible, please provide a link to a StackBlitz/CodeSandbox/Codepen project or a GitHub repository that demonstrates the issue. You can use the following template on StackBlitz to get started: https://stackblitz.com/edit/create-preact-starter

Steps to reproduce the behavior:

  1. Go to https://codepen.io/lukewarlow/pen/wBMjmJM
  2. Click on "Toggle HTML" twice
  3. Open browser dev tools and see the Trusted Types violation (will need Chromium or Safari 26+)

Expected behavior
What should have happened when following the steps above?

The text should toggle between the two values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions