Skip to content

Conversation

@lukewarlow
Copy link
Contributor

…HTML automatically

Need to see if there's tests for this, and how to update them.

@coveralls
Copy link

coveralls commented Oct 23, 2025

Coverage Status

coverage: 99.535%. remained the same
when pulling 428bace on lukewarlow:update-dangerouslySetInnerHTML-types-for-tt
into 5e18356 on preactjs:main.

@lukewarlow lukewarlow force-pushed the update-dangerouslySetInnerHTML-types-for-tt branch from 2c22cb1 to 428bace Compare October 23, 2025 18:29
Copy link
Member

@rschristian rschristian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Just to expound: parseFromString should take A TrustedHTML or string instance defining HTML to be parsed., though TS has yet to update lib/dom.d.ts to account for this. The method here should in theory be future proof though and collect the correct types for .innerHTML when/if TS makes them available.

Quite crafty

@lukewarlow lukewarlow marked this pull request as ready for review October 23, 2025 19:03
@lukewarlow
Copy link
Contributor Author

To provide a bit of extra detail we can't do something using innerHTML itself as that is currently a property but might become a getter setter pair and there's not a TS way to handle both those cases, nor does there seem to be a way to get the setter type, so this is a hack to get string | TrustedHTML in a workable way.

@rschristian rschristian merged commit 078ed0e into preactjs:main Oct 23, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants