Skip to content

Commit

Permalink
chore(client): remove redundant if statement (#14137)
Browse files Browse the repository at this point in the history
  • Loading branch information
btea authored Aug 18, 2023
1 parent 89fc794 commit fe1c0b9
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions packages/vite/src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,12 @@ function notifyListeners(event: string, data: any): void {
const enableOverlay = __HMR_ENABLE_OVERLAY__

function createErrorOverlay(err: ErrorPayload['err']) {
if (!enableOverlay) return
clearErrorOverlay()
document.body.appendChild(new ErrorOverlay(err))
}

function clearErrorOverlay() {
document
.querySelectorAll(overlayId)
.forEach((n) => (n as ErrorOverlay).close())
document.querySelectorAll<ErrorOverlay>(overlayId).forEach((n) => n.close())
}

function hasErrorOverlay() {
Expand Down Expand Up @@ -388,9 +385,11 @@ const sheetsMap = new Map<string, HTMLStyleElement>()
// collect existing style elements that may have been inserted during SSR
// to avoid FOUC or duplicate styles
if ('document' in globalThis) {
document.querySelectorAll('style[data-vite-dev-id]').forEach((el) => {
sheetsMap.set(el.getAttribute('data-vite-dev-id')!, el as HTMLStyleElement)
})
document
.querySelectorAll<HTMLStyleElement>('style[data-vite-dev-id]')
.forEach((el) => {
sheetsMap.set(el.getAttribute('data-vite-dev-id')!, el)
})
}

// all css imports should be inserted at the same position
Expand Down

0 comments on commit fe1c0b9

Please sign in to comment.