Skip to content

Commit

Permalink
Fixes an issue where normalizeProps overrides explicitly defined
Browse files Browse the repository at this point in the history
className

(cherry picked from commit 4408cf7)
  • Loading branch information
Sampo Kivistö committed Aug 21, 2021
1 parent 6480b05 commit 592e065
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions packages/inferno/__tests__/rendering.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,18 @@ describe('rendering routine', () => {
});
});

describe('className', () => {
it('Should override destructured property when defined', function () {
const testObj = {
className: 'test'
};

render(<div {...testObj} className="bar" />, container);

expect(container.innerHTML).toEqual('<div class="bar"></div>');
});
});

describe('Swapping children', () => {
it('Swapping children in component should affect hoisted children', () => {
class Hello extends Component {
Expand Down
4 changes: 3 additions & 1 deletion packages/inferno/src/core/implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ export function normalizeProps(vNode) {
normalizeChildren(vNode, props.children);
}
if (props.className !== void 0) {
vNode.className = props.className || null;
if (isNullOrUndef(vNode.className)) {
vNode.className = props.className || null;
}
props.className = undefined;
}
}
Expand Down

0 comments on commit 592e065

Please sign in to comment.