If you don't care about security, just run below JS command before you insert any HTML nodes or JS scripts:
window.trustedTypes.createPolicy('default', { createHTML: str => str, createScriptURL: str=> str, createScript: str=> str, });