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

feat: convert overlay template to DOM #15852

Merged
merged 9 commits into from
Mar 12, 2024
10 changes: 10 additions & 0 deletions packages/vite/src/client/overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@ export class ErrorOverlay extends HTMLElement {
constructor(err: ErrorPayload['err'], links = true) {
super()
this.root = this.attachShadow({ mode: 'open' })

if (typeof trustedTypes !== 'undefined') {
const sanitizer = trustedTypes.createPolicy('error-overlay', {
createHTML: (t: string) => t,
})
this.root.innerHTML = sanitizer.createHTML(template)
} else {
this.root.innerHTML = template
}

Snugug marked this conversation as resolved.
Show resolved Hide resolved
this.root.innerHTML = template

codeframeRE.lastIndex = 0
Expand Down