@@ -1015,6 +1015,43 @@ describe('compiler: parse', () => {
1015
1015
} )
1016
1016
} )
1017
1017
1018
+ test ( 'directive with dynamic argument' , ( ) => {
1019
+ const ast = baseParse ( '<div v-on:[event]/>' )
1020
+ const directive = ( ast . children [ 0 ] as ElementNode ) . props [ 0 ]
1021
+
1022
+ expect ( directive ) . toStrictEqual ( {
1023
+ type : NodeTypes . DIRECTIVE ,
1024
+ name : 'on' ,
1025
+ arg : {
1026
+ type : NodeTypes . SIMPLE_EXPRESSION ,
1027
+ content : 'event' ,
1028
+ isStatic : false ,
1029
+ isConstant : false ,
1030
+
1031
+ loc : {
1032
+ source : '[event]' ,
1033
+ start : {
1034
+ column : 11 ,
1035
+ line : 1 ,
1036
+ offset : 10
1037
+ } ,
1038
+ end : {
1039
+ column : 18 ,
1040
+ line : 1 ,
1041
+ offset : 17
1042
+ }
1043
+ }
1044
+ } ,
1045
+ modifiers : [ ] ,
1046
+ exp : undefined ,
1047
+ loc : {
1048
+ start : { offset : 5 , line : 1 , column : 6 } ,
1049
+ end : { offset : 17 , line : 1 , column : 18 } ,
1050
+ source : 'v-on:[event]'
1051
+ }
1052
+ } )
1053
+ } )
1054
+
1018
1055
test ( 'directive with a modifier' , ( ) => {
1019
1056
const ast = baseParse ( '<div v-on.enter/>' )
1020
1057
const directive = ( ast . children [ 0 ] as ElementNode ) . props [ 0 ]
@@ -1088,6 +1125,43 @@ describe('compiler: parse', () => {
1088
1125
} )
1089
1126
} )
1090
1127
1128
+ test ( 'directive with dynamic argument and modifiers' , ( ) => {
1129
+ const ast = baseParse ( '<div v-on:[a.b].camel/>' )
1130
+ const directive = ( ast . children [ 0 ] as ElementNode ) . props [ 0 ]
1131
+
1132
+ expect ( directive ) . toStrictEqual ( {
1133
+ type : NodeTypes . DIRECTIVE ,
1134
+ name : 'on' ,
1135
+ arg : {
1136
+ type : NodeTypes . SIMPLE_EXPRESSION ,
1137
+ content : 'a.b' ,
1138
+ isStatic : false ,
1139
+ isConstant : false ,
1140
+
1141
+ loc : {
1142
+ source : '[a.b]' ,
1143
+ start : {
1144
+ column : 11 ,
1145
+ line : 1 ,
1146
+ offset : 10
1147
+ } ,
1148
+ end : {
1149
+ column : 16 ,
1150
+ line : 1 ,
1151
+ offset : 15
1152
+ }
1153
+ }
1154
+ } ,
1155
+ modifiers : [ 'camel' ] ,
1156
+ exp : undefined ,
1157
+ loc : {
1158
+ start : { offset : 5 , line : 1 , column : 6 } ,
1159
+ end : { offset : 21 , line : 1 , column : 22 } ,
1160
+ source : 'v-on:[a.b].camel'
1161
+ }
1162
+ } )
1163
+ } )
1164
+
1091
1165
test ( 'v-bind shorthand' , ( ) => {
1092
1166
const ast = baseParse ( '<div :a=b />' )
1093
1167
const directive = ( ast . children [ 0 ] as ElementNode ) . props [ 0 ]
0 commit comments