refactor(ssr): move escapeHtml to shared
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { compile } from '../../src'
|
||||
import { compile } from '../src'
|
||||
|
||||
function getElementString(src: string): string {
|
||||
return compile(src).code.match(/_push\((.*)\)/)![1]
|
||||
}
|
||||
|
||||
describe('ssr transform element', () => {
|
||||
describe('ssr compile integration test', () => {
|
||||
test('basic elements', () => {
|
||||
expect(getElementString(`<div></div>`)).toMatchInlineSnapshot(
|
||||
`"\`<div></div>\`"`
|
||||
@@ -22,4 +22,12 @@ describe('ssr transform element', () => {
|
||||
getElementString(`<div><span></span><span></span></div>`)
|
||||
).toMatchInlineSnapshot(`"\`<div><span></span><span></span></div>\`"`)
|
||||
})
|
||||
|
||||
test('nested elements with static text', () => {
|
||||
expect(
|
||||
getElementString(`<div><span>hello</span>><span>bye</span></div>`)
|
||||
).toMatchInlineSnapshot(
|
||||
`"\`<div><span>hello</span>><span>bye</span></div>\`"`
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
ElementTypes,
|
||||
createBlockStatement
|
||||
} from '@vue/compiler-dom'
|
||||
import { isString } from '@vue/shared'
|
||||
import { isString, escapeHtml } from '@vue/shared'
|
||||
|
||||
// Because SSR codegen output is completely different from client-side output
|
||||
// (e.g. multiple elements can be concatenated into a single template literal
|
||||
@@ -85,7 +85,7 @@ function processChildren(
|
||||
// TODO
|
||||
}
|
||||
} else if (child.type === NodeTypes.TEXT) {
|
||||
// TODO
|
||||
context.pushStringPart(escapeHtml(child.content))
|
||||
} else if (child.type === NodeTypes.IF) {
|
||||
// TODO
|
||||
} else if (child.type === NodeTypes.FOR) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
TemplateLiteral,
|
||||
createTemplateLiteral
|
||||
} from '@vue/compiler-dom'
|
||||
import { escapeHtml } from '@vue/server-renderer'
|
||||
import { escapeHtml } from '@vue/shared'
|
||||
|
||||
/*
|
||||
## Simple Element
|
||||
|
||||
Reference in New Issue
Block a user