test: add compat code for vite v6 (#29677)

This commit is contained in:
翠 / green 2024-10-25 17:54:35 +09:00 committed by Daniel Roe
parent 85514f212c
commit 084471ce09
No known key found for this signature in database
GPG Key ID: CBC814C393D93268

View File

@ -2377,7 +2377,7 @@ describe('component islands', () => {
"link": [],
"style": [
{
"innerHTML": "pre[data-v-xxxxx]{color:blue}",
"innerHTML": "pre[data-v-xxxxx]{color:#00f}",
},
],
}
@ -2746,7 +2746,11 @@ function normaliseIslandResult (result: NuxtIslandResponse) {
for (const style of result.head.style) {
if (typeof style !== 'string') {
if (style.innerHTML) {
style.innerHTML = (style.innerHTML as string).replace(/data-v-[a-z0-9]+/g, 'data-v-xxxxx')
style.innerHTML =
(style.innerHTML as string)
.replace(/data-v-[a-z0-9]+/g, 'data-v-xxxxx')
// Vite 6 enables CSS minify by default for SSR
.replace(/blue/, '#00f')
}
if (style.key) {
style.key = style.key.replace(/-[a-z0-9]+$/i, '')