File tree 3 files changed +29
-8
lines changed
3 files changed +29
-8
lines changed Original file line number Diff line number Diff line change
1
+ import { compile } from '../../src'
2
+
3
+ function getElementString ( src : string ) : string {
4
+ return compile ( src ) . code . match ( / _ p u s h \( ( .* ) \) / ) ! [ 1 ]
5
+ }
6
+
7
+ describe ( 'ssr transform element' , ( ) => {
8
+ test ( 'basic elements' , ( ) => {
9
+ expect ( getElementString ( `<div></div>` ) ) . toMatchInlineSnapshot (
10
+ `"\`<div></div>\`"`
11
+ )
12
+ } )
13
+
14
+ test ( 'static attrs' , ( ) => {
15
+ expect (
16
+ getElementString ( `<div id="foo" class="bar"></div>` )
17
+ ) . toMatchInlineSnapshot ( `"\`<div id=\\"foo\\" class=\\"bar\\"></div>\`"` )
18
+ } )
19
+
20
+ test ( 'nested elements' , ( ) => {
21
+ expect (
22
+ getElementString ( `<div><span></span><span></span></div>` )
23
+ ) . toMatchInlineSnapshot ( `"\`<div><span></span><span></span></div>\`"` )
24
+ } )
25
+ } )
Original file line number Diff line number Diff line change @@ -5,10 +5,10 @@ import {
5
5
TemplateLiteral ,
6
6
createCallExpression ,
7
7
createTemplateLiteral ,
8
- locStub ,
9
8
NodeTypes ,
10
9
TemplateChildNode ,
11
- ElementTypes
10
+ ElementTypes ,
11
+ createBlockStatement
12
12
} from '@vue/compiler-dom'
13
13
import { isString } from '@vue/shared'
14
14
@@ -30,11 +30,7 @@ export function ssrCodegenTransform(ast: RootNode) {
30
30
context . pushStringPart ( `<!---->` )
31
31
}
32
32
33
- ast . codegenNode = {
34
- type : NodeTypes . JS_BLOCK_STATEMENT ,
35
- loc : locStub ,
36
- body : context . body
37
- }
33
+ ast . codegenNode = createBlockStatement ( context . body )
38
34
}
39
35
40
36
type SSRTransformContext = ReturnType < typeof createSSRTransformContext >
Original file line number Diff line number Diff line change 5
5
TemplateLiteral ,
6
6
createTemplateLiteral
7
7
} from '@vue/compiler-dom'
8
- import { escapeHtml } from '@vue/server-renderer/src '
8
+ import { escapeHtml } from '@vue/server-renderer'
9
9
10
10
/*
11
11
## Simple Element
You can’t perform that action at this time.
0 commit comments