@@ -43,6 +43,18 @@ const originalCode = `
43
43
</div>
44
44
` . trim ( )
45
45
46
+ const tagCouldBeAttrCode = `
47
+ <div>
48
+ <b text-red>Test</b>
49
+ <h1 text-red>Test</h1>
50
+ <h2 text-red>Test</h2>
51
+ <h3 text-red>Test</h3>
52
+ <h4 text-red>Test</h4>
53
+ <h5 text-red>Test</h5>
54
+ <h6 text-red>Test</h6>
55
+ </div>
56
+ ` . trim ( )
57
+
46
58
describe ( 'transformerAttributifyJsx' , ( ) => {
47
59
const uno = createGenerator ( {
48
60
presets : [
@@ -146,6 +158,23 @@ describe('transformerAttributifyJsx', () => {
146
158
expect ( codeToString ) . not . toMatch ( `${ rule } =""` )
147
159
} )
148
160
} )
161
+
162
+ test ( 'if class-like tag do not cause error' , async ( ) => {
163
+ const code = new MagicString ( tagCouldBeAttrCode )
164
+ await transformerAttributifyJsx ( ) . transform ( code , 'app.tsx' , { uno, tokens : new Set ( ) } as any )
165
+
166
+ expect ( code . toString ( ) ) . toMatchInlineSnapshot ( `
167
+ "<div>
168
+ <b text-red=\\"\\">Test</b>
169
+ <h1 text-red=\\"\\">Test</h1>
170
+ <h2 text-red=\\"\\">Test</h2>
171
+ <h3 text-red=\\"\\">Test</h3>
172
+ <h4 text-red=\\"\\">Test</h4>
173
+ <h5 text-red=\\"\\">Test</h5>
174
+ <h6 text-red=\\"\\">Test</h6>
175
+ </div>"
176
+ ` )
177
+ } )
149
178
} )
150
179
151
180
describe ( 'transformerAttributifyJsxBabel' , ( ) => {
@@ -237,4 +266,21 @@ describe('transformerAttributifyJsxBabel', () => {
237
266
expect ( codeToString ) . not . toMatch ( `${ rule } =""` )
238
267
} )
239
268
} )
269
+
270
+ test ( 'if class-like tag do not cause error' , async ( ) => {
271
+ const code = new MagicString ( tagCouldBeAttrCode )
272
+ await transformerAttributifyJsx ( ) . transform ( code , 'app.tsx' , { uno, tokens : new Set ( ) } as any )
273
+
274
+ expect ( code . toString ( ) ) . toMatchInlineSnapshot ( `
275
+ "<div>
276
+ <b text-red=\\"\\">Test</b>
277
+ <h1 text-red=\\"\\">Test</h1>
278
+ <h2 text-red=\\"\\">Test</h2>
279
+ <h3 text-red=\\"\\">Test</h3>
280
+ <h4 text-red=\\"\\">Test</h4>
281
+ <h5 text-red=\\"\\">Test</h5>
282
+ <h6 text-red=\\"\\">Test</h6>
283
+ </div>"
284
+ ` )
285
+ } )
240
286
} )
0 commit comments