Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions client/app/components/HydrationIssue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,28 @@
const diffHtml = ref('')

async function render(pre: string, post: string) {
const diff = diffLines(pre, post, { stripTrailingCr: true, ignoreNewlineAtEof: true })
const diff = diffLines(pre, post, { stripTrailingCr: true, ignoreNewlineAtEof: true, newlineIsToken: true, ignoreWhitespace: true })
diffHtml.value = await codeToHtml(generateDiffHtml(diff), {
theme: 'github-dark', lang: 'html', transformers: [
transformerNotationDiff(),
],
})
}

function generateDiffHtml(change: ChangeObject<string>[]) {
return change.map((part) => {
if (part.value === '\n') {
return ''
}
if (part.added) {
return `// [!code ++]\n${part.value}`
return `\n// [!code ++]\n${part.value}`
}
else if (part.removed) {
return `// [!code --]\n${part.value} `
return `\n// [!code --]\n${part.value} `
}
else {
return part.value
}
}).join('')
}).join('').trim()
}

const fullPre = computed(() => props.issue.htmlPreHydration ?? '')
Expand Down Expand Up @@ -140,8 +142,8 @@
</div>

<div
class="w-full mt-3 overflow-auto rounded-lg w-fit"
class="w-full mt-3 overflow-auto rounded-lg"
v-html="diffHtml"

Check warning on line 146 in client/app/components/HydrationIssue.vue

View workflow job for this annotation

GitHub Actions / ci

'v-html' directive can lead to XSS attack
/>
</n-card>
</template>
Expand Down
11 changes: 10 additions & 1 deletion playground/pages/hydration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@

<template>
<div>
<p>isServer: {{ isServer }}</p>
<p :data-test="isServer ? 'server' : 'client'" class="fzejkebkzjefbjkzebfkjzebfkjzebfzebfkjzebkfjbzekjjjjjjjjjjjjjjjjjjjjkfzebjkfbzkjebfjkjk">

Check warning on line 7 in playground/pages/hydration.vue

View workflow job for this annotation

GitHub Actions / ci

'class' should be on a new line
isServer: {{ isServer }} <span v-if="!isServer">test</span>
</p>

<div
:class="isServer ? '1561561' : 'text-green-500'"
:data-test="isServer ? 'server' : 'client'"
>
yolooo
</div>
</div>
</template>
Loading