Skip to content

Commit

Permalink
perf(ssr): improve isComment check (#6078)
Browse files Browse the repository at this point in the history
  • Loading branch information
hkk12369 committed Jun 13, 2022
1 parent 19236d2 commit 25f7a16
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/server-renderer/src/helpers/ssrRenderSlot.ts
Expand Up @@ -87,11 +87,11 @@ export function ssrRenderSlotInner(
}
}

const commentTestRE = /^<!--.*-->$/s
const commentRE = /<!--[^]*?-->/gm
function isComment(item: SSRBufferItem) {
return (
typeof item === 'string' &&
commentRE.test(item) &&
!item.replace(commentRE, '').trim()
)
if (typeof item !== 'string' || !commentTestRE.test(item)) return false
// if item is '<!---->' or '<!--[-->' or '<!--]-->', return true directly
if (item.length <= 8) return true
return !item.replace(commentRE, '').trim()
}

0 comments on commit 25f7a16

Please sign in to comment.