@@ -35,6 +35,10 @@ const isEventRegex = /^on[A-Z]/
3535const isDirectiveRegex = / ^ v - [ a - z ] /
3636
3737export const transformElement : NodeTransform = ( node , context ) => {
38+ let effectIndex = context . block . effect . length
39+ const getEffectIndex = ( ) => effectIndex ++
40+ let operationIndex = context . block . operation . length
41+ const getOperationIndex = ( ) => operationIndex ++
3842 return function postTransformElement ( ) {
3943 ; ( { node } = context )
4044 if ( node . type !== 'JSXElement' || isTemplate ( node ) ) return
@@ -71,6 +75,8 @@ export const transformElement: NodeTransform = (node, context) => {
7175 propsResult ,
7276 singleRoot ,
7377 context as TransformContext < JSXElement > ,
78+ getEffectIndex ,
79+ getOperationIndex ,
7480 )
7581 }
7682}
@@ -120,6 +126,8 @@ function transformNativeElement(
120126 propsResult : PropsResult ,
121127 singleRoot : boolean ,
122128 context : TransformContext < JSXElement > ,
129+ getEffectIndex : ( ) => number ,
130+ getOperationIndex : ( ) => number ,
123131) {
124132 const { scopeId } = context . options
125133
@@ -131,12 +139,17 @@ function transformNativeElement(
131139 const dynamicProps : string [ ] = [ ]
132140 if ( propsResult [ 0 ] /* dynamic props */ ) {
133141 const [ , dynamicArgs , expressions ] = propsResult
134- context . registerEffect ( expressions , {
135- type : IRNodeTypes . SET_DYNAMIC_PROPS ,
136- element : context . reference ( ) ,
137- props : dynamicArgs ,
138- root : singleRoot ,
139- } )
142+ context . registerEffect (
143+ expressions ,
144+ {
145+ type : IRNodeTypes . SET_DYNAMIC_PROPS ,
146+ element : context . reference ( ) ,
147+ props : dynamicArgs ,
148+ root : singleRoot ,
149+ } ,
150+ getEffectIndex ,
151+ getOperationIndex ,
152+ )
140153 } else {
141154 for ( const prop of propsResult [ 1 ] ) {
142155 const { key, values } = prop
@@ -145,13 +158,18 @@ function transformNativeElement(
145158 if ( values [ 0 ] . content ) template += `="${ values [ 0 ] . content } "`
146159 } else {
147160 dynamicProps . push ( key . content )
148- context . registerEffect ( values , {
149- type : IRNodeTypes . SET_PROP ,
150- element : context . reference ( ) ,
151- prop,
152- tag,
153- root : singleRoot ,
154- } )
161+ context . registerEffect (
162+ values ,
163+ {
164+ type : IRNodeTypes . SET_PROP ,
165+ element : context . reference ( ) ,
166+ prop,
167+ tag,
168+ root : singleRoot ,
169+ } ,
170+ getEffectIndex ,
171+ getOperationIndex ,
172+ )
155173 }
156174 }
157175 }
0 commit comments