@@ -35,6 +35,10 @@ const isEventRegex = /^on[A-Z]/
35
35
const isDirectiveRegex = / ^ v - [ a - z ] /
36
36
37
37
export 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 ++
38
42
return function postTransformElement ( ) {
39
43
; ( { node } = context )
40
44
if ( node . type !== 'JSXElement' || isTemplate ( node ) ) return
@@ -71,6 +75,8 @@ export const transformElement: NodeTransform = (node, context) => {
71
75
propsResult ,
72
76
singleRoot ,
73
77
context as TransformContext < JSXElement > ,
78
+ getEffectIndex ,
79
+ getOperationIndex ,
74
80
)
75
81
}
76
82
}
@@ -120,6 +126,8 @@ function transformNativeElement(
120
126
propsResult : PropsResult ,
121
127
singleRoot : boolean ,
122
128
context : TransformContext < JSXElement > ,
129
+ getEffectIndex : ( ) => number ,
130
+ getOperationIndex : ( ) => number ,
123
131
) {
124
132
const { scopeId } = context . options
125
133
@@ -131,12 +139,17 @@ function transformNativeElement(
131
139
const dynamicProps : string [ ] = [ ]
132
140
if ( propsResult [ 0 ] /* dynamic props */ ) {
133
141
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
+ )
140
153
} else {
141
154
for ( const prop of propsResult [ 1 ] ) {
142
155
const { key, values } = prop
@@ -145,13 +158,18 @@ function transformNativeElement(
145
158
if ( values [ 0 ] . content ) template += `="${ values [ 0 ] . content } "`
146
159
} else {
147
160
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
+ )
155
173
}
156
174
}
157
175
}
0 commit comments