11import { describe , expect , test } from 'vitest'
22
3+ import { NodeTypes } from '@vue-vapor/compiler-core'
4+ import { IRDynamicPropsKind , IRNodeTypes } from '@vue-vapor/compiler-vapor'
35import {
46 transformChildren ,
57 transformElement ,
68 transformText ,
9+ transformVBind ,
710 // transformVIf,
811} from '../../src/core/compiler'
912import { makeCompile } from './_utils'
@@ -15,6 +18,7 @@ const compileWithElementTransform = makeCompile({
1518 transformElement ,
1619 transformChildren ,
1720 ] ,
21+ directiveTransforms : { bind : transformVBind } ,
1822} )
1923
2024describe ( 'compiler: children transform' , ( ) => {
@@ -52,4 +56,46 @@ describe('compiler: children transform', () => {
5256 'template' ,
5357 ] )
5458 } )
59+
60+ test . only ( 'v-bind="obj"' , ( ) => {
61+ const { code, ir } = compileWithElementTransform ( `<div {...obj} />` )
62+ expect ( code ) . toMatchInlineSnapshot ( `
63+ "import { renderEffect as _renderEffect, setDynamicProps as _setDynamicProps, template as _template } from 'vue/vapor';
64+ const t0 = _template("<div></div>")
65+
66+ export function render(_ctx) {
67+ const n0 = t0()
68+ _renderEffect(() => _setDynamicProps(n0, _ctx.obj))
69+ return n0
70+ }"
71+ ` )
72+ expect ( ir . block . effect ) . toMatchObject ( [
73+ {
74+ expressions : [
75+ {
76+ type : NodeTypes . SIMPLE_EXPRESSION ,
77+ content : 'obj' ,
78+ isStatic : false ,
79+ } ,
80+ ] ,
81+ operations : [
82+ {
83+ type : IRNodeTypes . SET_DYNAMIC_PROPS ,
84+ element : 0 ,
85+ props : [
86+ {
87+ kind : IRDynamicPropsKind . EXPRESSION ,
88+ value : {
89+ type : NodeTypes . SIMPLE_EXPRESSION ,
90+ content : 'obj' ,
91+ isStatic : false ,
92+ } ,
93+ } ,
94+ ] ,
95+ } ,
96+ ] ,
97+ } ,
98+ ] )
99+ expect ( code ) . contains ( '_setDynamicProps(n0, _ctx.obj)' )
100+ } )
55101} )
0 commit comments