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

Commit

Permalink
fix: 修复 style props 变更的错误异常 (#1446)
Browse files Browse the repository at this point in the history
* test: 增加 freeze 测试用例

* fix: props freeze
  • Loading branch information
noyobo committed Dec 17, 2020
1 parent d3ffc98 commit 44d43a7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ describe('diffProperties', () => {
expect(!!diffProperties({ autoFocus: true }, {})).toBeTruthy();
expect(!!diffProperties({ children: '1' }, {})).toBeTruthy();

const lastProps = { style: { width: 1 } };
const nextProps = { style: { width: 2, height: 1 } };
diffProperties(lastProps, nextProps);
diffProperties(nextProps, { style: { width: 3, height: 1 } });
expect(nextProps).toMatchObject({ style: { width: 2, height: 1 } });
expect(lastProps).toMatchObject({ style: { width: 1 } });
const update = () => {
nextProps.style = { width: 3, height: 1 };
};
expect(update()).toBeUndefined();
expect(nextProps).toMatchObject({ style: { width: 3, height: 1 } });

const sameFn = () => void 0;
expect(!!diffProperties({ a: sameFn }, { a: sameFn })).toBeFalsy();
expect(!!diffProperties({ a: () => void 0 }, { a: () => void 0 })).toBeTruthy();
Expand Down
2 changes: 1 addition & 1 deletion packages/remax-runtime/src/hostConfig/diffProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default function diffProperties(
for (const styleKey in styleUpdates) {
const styleValue = styleUpdates[styleKey];
if (styleValue) {
updatePayload.push(styleKey, Object.assign(lastProps[styleKey] || {}, styleValue));
updatePayload.push(styleKey, Object.assign({}, lastProps[styleKey], styleValue));
}
}

Expand Down

1 comment on commit 44d43a7

@vercel
Copy link

@vercel vercel bot commented on 44d43a7 Dec 17, 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.