Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

Commit

Permalink
fix(ali): 修复条件渲染 JSX 可能导致报错的问题 (#1092)
Browse files Browse the repository at this point in the history
  • Loading branch information
yesmeck committed Jun 16, 2020
1 parent 6b9c0a1 commit 309bc5b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,14 @@ describe('diffProperties', () => {
).toBeFalsy();

expect(!!diffProperties({ children: '1' }, { children: 1 })).toBeTruthy();

expect(diffProperties({ className: 'foo' }, { style: { width: 5 } })).toEqual([
'className',
'',
'style',
null,
'style',
{ width: 5 },
]);
});
});
3 changes: 2 additions & 1 deletion packages/remax-runtime/src/hostConfig/diffProperties.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const STYLE = 'style';
const CHILDREN = 'children';
const CLASS_NAME = 'className';

export default function diffProperties(
lastRawProps: Record<string, any> | null | undefined,
Expand Down Expand Up @@ -35,7 +36,7 @@ export default function diffProperties(
} else {
// For all other deleted properties we add it to the queue. We use
// the whitelist in the commit phase instead.
(updatePayload = updatePayload || []).push(propKey, null);
(updatePayload = updatePayload || []).push(propKey, propKey === CLASS_NAME ? '' : null);
}
}

Expand Down

1 comment on commit 309bc5b

@vercel
Copy link

@vercel vercel bot commented on 309bc5b Jun 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.