Skip to content

Commit a1cc58e

Browse files
committed
Fix comment issue
1 parent 2aa3911 commit a1cc58e

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

src/__tests__/Element.test.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ describe('Element', () => {
358358
],
359359
}),
360360
createNode('VECTOR', {
361+
name: 'image',
361362
width: '17.003px',
362363
height: '28.741px',
363364
'flex-shrink': '0',
@@ -369,7 +370,7 @@ describe('Element', () => {
369370
expect(await element.render()).toEqual(
370371
`<Flex alignItems="center">
371372
<Image boxSize="60px" src="image" />
372-
<Image w="17px" h="28px" src="undefined" />
373+
<Image w="17px" h="28px" src="image" />
373374
</Flex>`,
374375
)
375376
})
@@ -528,10 +529,23 @@ describe('Element', () => {
528529

529530
describe('Text', () => {
530531
it('should render Text', async () => {
531-
const element = createElement('TEXT')
532-
expect(await element.getComponentType()).toEqual('Text')
533-
expect(await element.render()).toEqual('<Text />')
532+
{
533+
const element = createElement('TEXT')
534+
expect(await element.getComponentType()).toEqual('Text')
535+
expect(await element.render()).toEqual('<Text />')
536+
}
537+
{
538+
const element = createElement('TEXT', {
539+
fontFamily: '"Roboto"',
540+
lineHeight: '30px /* 157.895% */',
541+
})
542+
expect(await element.getComponentType()).toEqual('Text')
543+
expect(await element.render()).toEqual(
544+
'<Text fontFamily="Roboto" lineHeight="30px" />',
545+
)
546+
}
534547
})
548+
535549
it('should render Text with char', async () => {
536550
const element = createElement('TEXT', {
537551
characters: 'a',

src/utils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,13 @@ export function organizeProps(props: Record<string, string>) {
424424
}
425425
}
426426
for (const key in ret) {
427-
if (ret[key] === '') {
427+
if (!ret[key]) {
428428
delete ret[key]
429+
continue
429430
}
431+
if (ret[key].startsWith('"') && ret[key].endsWith('"'))
432+
ret[key] = ret[key].slice(1, -1)
433+
if (ret[key].includes('/*')) ret[key] = ret[key].split('/*')[0].trim()
430434
}
431435
for (const key in CONVERT_PROPS_VALUE_MAP) {
432436
if (!ret[key]) continue

0 commit comments

Comments
 (0)