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

Commit

Permalink
fix: 修复 style 属性为 null 时报错的问题 (#1066)
Browse files Browse the repository at this point in the history
fix #1065
  • Loading branch information
dominicleo committed Jun 10, 2020
1 parent f795944 commit ff83df3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 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 @@ -5,3 +5,9 @@ Object {
"style": "color:#ffffff;height:2rpx;-webkit-flex:1;--color:red;--textColor:blue;background-color:var(--textColor);",
}
`;

exports[`props alias transform style prop correctly 2`] = `
Object {
"style": null,
}
`;
9 changes: 9 additions & 0 deletions packages/remax-runtime/src/__tests__/propsAlias.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ describe('props alias', () => {
'any'
)
).toMatchSnapshot();

expect(
propsAlias(
{
style: null,
},
'any'
)
).toMatchSnapshot();
});

it('transform props by component type correctly', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/remax-runtime/src/propsAlias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function getAlias(prop: string, type: string) {
}

function getValue(prop: string, value: any): any {
if (prop.toLowerCase().endsWith('style') && typeof value === 'object') {
if (prop.toLowerCase().endsWith('style') && Object.prototype.toString.call(value) === '[object Object]') {
return plainStyle(value);
}

Expand Down

1 comment on commit ff83df3

@vercel
Copy link

@vercel vercel bot commented on ff83df3 Jun 10, 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.