@@ -61,6 +61,27 @@ test('estree-util-build-jsx', function (t) {
6161 'should support `pragma`, `pragmaFrag`'
6262 )
6363
64+ t . deepEqual (
65+ build ( parse ( '<x />' ) , { pragma : 'a.b-c' } ) . body [ 0 ] . expression ,
66+ {
67+ type : 'CallExpression' ,
68+ callee : {
69+ type : 'MemberExpression' ,
70+ object : { type : 'Identifier' , name : 'a' } ,
71+ property : { type : 'Literal' , value : 'b-c' } ,
72+ computed : true
73+ } ,
74+ arguments : [ { type : 'Literal' , value : 'x' } ]
75+ } ,
76+ 'should support `pragma` w/ non-identifiers (1)'
77+ )
78+
79+ t . equal (
80+ astring . generate ( build ( parse ( '<x />' ) , { pragma : 'a.b-c' } ) ) ,
81+ 'a["b-c"]("x");\n' ,
82+ 'should support `pragma` w/ non-identifiers (2)'
83+ )
84+
6485 t . deepEqual (
6586 build ( parse ( '/* @jsx a @jsxFrag b */\n<><x /></>' ) ) . body [ 0 ] . expression ,
6687 {
@@ -181,6 +202,51 @@ test('estree-util-build-jsx', function (t) {
181202 'should support dots in a tag name for member expressions'
182203 )
183204
205+ t . deepEqual (
206+ build ( parse ( '<a.b-c />' ) , { pragma : 'h' } ) . body [ 0 ] . expression ,
207+ {
208+ type : 'CallExpression' ,
209+ callee : { type : 'Identifier' , name : 'h' } ,
210+ arguments : [
211+ {
212+ type : 'MemberExpression' ,
213+ object : { type : 'Identifier' , name : 'a' } ,
214+ property : { type : 'Literal' , value : 'b-c' } ,
215+ computed : true
216+ }
217+ ]
218+ } ,
219+ 'should support dots *and* dashes in tag names (1)'
220+ )
221+
222+ t . equal (
223+ astring . generate ( build ( parse ( '<a.b-c />' ) , { pragma : 'h' } ) ) ,
224+ 'h(a["b-c"]);\n' ,
225+ 'should support dots *and* dashes in tag names (2)'
226+ )
227+
228+ t . deepEqual (
229+ build ( parse ( '<a-b.c />' ) , { pragma : 'h' } ) . body [ 0 ] . expression ,
230+ {
231+ type : 'CallExpression' ,
232+ callee : { type : 'Identifier' , name : 'h' } ,
233+ arguments : [
234+ {
235+ type : 'MemberExpression' ,
236+ object : { type : 'Literal' , value : 'a-b' } ,
237+ property : { type : 'Identifier' , name : 'c' }
238+ }
239+ ]
240+ } ,
241+ 'should support dots *and* dashes in tag names (3)'
242+ )
243+
244+ t . equal (
245+ astring . generate ( build ( parse ( '<a-b.c />' ) , { pragma : 'h' } ) ) ,
246+ 'h(("a-b").c);\n' ,
247+ 'should support dots *and* dashes in tag names (4)'
248+ )
249+
184250 t . deepEqual (
185251 build ( parse ( '<a.b.c.d />' ) , { pragma : 'h' } ) . body [ 0 ] . expression ,
186252 {
0 commit comments