Skip to content

Commit

Permalink
Merge pull request #653 from edli/dev
Browse files Browse the repository at this point in the history
fix(normalization): issue-648, remove props.key and props.ref
  • Loading branch information
Havunen authored Dec 30, 2016
2 parents 2bb727c + 9ec4982 commit e0252e4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
39 changes: 39 additions & 0 deletions src/core/__tests__/normalizeProps.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { expect } from 'chai';
import { normalize } from '../normalization';
import { VNode } from '../structures';

describe('normalizeProps', () => {
it('should delete ref from props', () => {
const vNode: VNode = {
children: null,
dom: null,
events: null,
flags: 0,
key: null,
props: { ref: () => {} },
ref: null,
type: null
};

normalize(vNode);

expect(vNode.props).to.not.have.property('ref');
});

it('should delete key from props', () => {
const vNode: VNode = {
children: null,
dom: null,
events: null,
flags: 0,
key: null,
props: { key: 'key' },
ref: null,
type: null
};

normalize(vNode);

expect(vNode.props).to.not.have.property('key');
});
});
5 changes: 2 additions & 3 deletions src/core/normalization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,15 @@ function normalizeProps(vNode: VNode, props: Props, children: InfernoChildren) {
vNode.children = props.children;
}
if (props.ref) {
vNode.ref = props.ref;
delete props.ref;
}
if (props.key) {
delete props.key;
}
if (props.events) {
vNode.events = props.events;
}
if (!isNullOrUndef(props.key)) {
vNode.key = props.key;
delete props.key;
}
}

Expand Down

0 comments on commit e0252e4

Please sign in to comment.