@@ -24,9 +24,11 @@ import type {
24
24
} from '../transform'
25
25
import {
26
26
DynamicFlag ,
27
+ DynamicPropsKind ,
27
28
IRNodeTypes ,
28
29
type IRProp ,
29
30
type IRProps ,
31
+ type IRPropsDynamicAttribute ,
30
32
type VaporDirectiveNode ,
31
33
} from '../ir'
32
34
import { EMPTY_EXPRESSION } from './utils'
@@ -205,7 +207,10 @@ function buildProps(
205
207
if ( prop . exp ) {
206
208
dynamicExpr . push ( prop . exp )
207
209
pushMergeArg ( )
208
- dynamicArgs . push ( { value : prop . exp } )
210
+ dynamicArgs . push ( {
211
+ kind : DynamicPropsKind . EXPRESSION ,
212
+ value : prop . exp ,
213
+ } )
209
214
} else {
210
215
context . options . onError (
211
216
createCompilerError ( ErrorCodes . X_V_BIND_NO_EXPRESSION , prop . loc ) ,
@@ -218,7 +223,11 @@ function buildProps(
218
223
if ( isComponent ) {
219
224
dynamicExpr . push ( prop . exp )
220
225
pushMergeArg ( )
221
- dynamicArgs . push ( { value : prop . exp , handler : true } )
226
+ dynamicArgs . push ( {
227
+ kind : DynamicPropsKind . EXPRESSION ,
228
+ value : prop . exp ,
229
+ handler : true ,
230
+ } )
222
231
} else {
223
232
context . registerEffect (
224
233
[ prop . exp ] ,
@@ -245,7 +254,11 @@ function buildProps(
245
254
if ( isComponent && ! result . key . isStatic ) {
246
255
// v-bind:[name]="value" or v-on:[name]="value"
247
256
pushMergeArg ( )
248
- dynamicArgs . push ( normalizeIRProp ( result ) )
257
+ dynamicArgs . push (
258
+ extend ( resolveDirectiveResult ( result ) , {
259
+ kind : DynamicPropsKind . ATTRIBUTE ,
260
+ } ) as IRPropsDynamicAttribute ,
261
+ )
249
262
} else {
250
263
// other static props
251
264
results . push ( result )
@@ -304,7 +317,7 @@ function dedupeProperties(results: DirectiveTransformResult[]): IRProp[] {
304
317
const deduped : IRProp [ ] = [ ]
305
318
306
319
for ( const result of results ) {
307
- const prop = normalizeIRProp ( result )
320
+ const prop = resolveDirectiveResult ( result )
308
321
// dynamic keys are always allowed
309
322
if ( ! prop . key . isStatic ) {
310
323
deduped . push ( prop )
@@ -314,7 +327,7 @@ function dedupeProperties(results: DirectiveTransformResult[]): IRProp[] {
314
327
const existing = knownProps . get ( name )
315
328
if ( existing ) {
316
329
if ( name === 'style' || name === 'class' ) {
317
- mergeAsArray ( existing , prop )
330
+ mergePropValues ( existing , prop )
318
331
}
319
332
// unexpected duplicate, should have emitted error during parse
320
333
} else {
@@ -325,11 +338,14 @@ function dedupeProperties(results: DirectiveTransformResult[]): IRProp[] {
325
338
return deduped
326
339
}
327
340
328
- function normalizeIRProp ( prop : DirectiveTransformResult ) : IRProp {
329
- return extend ( { } , prop , { value : undefined , values : [ prop . value ] } )
341
+ function resolveDirectiveResult ( prop : DirectiveTransformResult ) : IRProp {
342
+ return extend ( { } , prop , {
343
+ value : undefined ,
344
+ values : [ prop . value ] ,
345
+ } )
330
346
}
331
347
332
- function mergeAsArray ( existing : IRProp , incoming : IRProp ) {
348
+ function mergePropValues ( existing : IRProp , incoming : IRProp ) {
333
349
const newValues = incoming . values
334
350
existing . values . push ( ...newValues )
335
351
}
0 commit comments