Skip to content

Commit

Permalink
fix: fix property transform
Browse files Browse the repository at this point in the history
  • Loading branch information
answershuto committed Sep 5, 2024
1 parent 97d82df commit 4626528
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
20 changes: 10 additions & 10 deletions packages/rax-compat/src/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ function transformProps(type: string, props: ComponentProps<JSXElementConstructo
}
}
// eslint-disable-next-line no-prototype-builtins
}

const needTransform = (type !== 'svg');
if (needTransform) {
if (Object.prototype.hasOwnProperty.call(possibleStandardNames, lowerCasedPropKey)) {
// Transform attribute names that make it works properly in React.
key = possibleStandardNames[lowerCasedPropKey];
} else {
// Handles component props from rax-components like resizeMode, this causes React to throw a warning.
key = lowerCasedPropKey;
} else {
const needTransform = (type !== 'svg');
if (needTransform) {
if (Object.prototype.hasOwnProperty.call(possibleStandardNames, lowerCasedPropKey)) {
// Transform attribute names that make it works properly in React.
key = possibleStandardNames[lowerCasedPropKey];
} else {
// Handles component props from rax-components like resizeMode, this causes React to throw a warning.
key = lowerCasedPropKey;
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions packages/rax-compat/tests/events.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ describe('events', () => {
});

it('should work with ondblclick', () => {
console.log('aaaaaa', transformProps('div', {
ondblclick: () => { },
}));
expect(transformProps('div', {
ondblclick: () => { },
}).onDoubleClick).toBeInstanceOf(Function);
Expand Down

0 comments on commit 4626528

Please sign in to comment.