Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Oct 31, 2020
1 parent b03ea7d commit 378d989
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
9 changes: 8 additions & 1 deletion compat/test/browser/cloneElement.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@ describe('compat cloneElement', () => {
a<span>b</span>
</foo>
);
expect(cloneElement(element)).to.eql(element);
const clone = cloneElement(element);
delete clone._original;
delete element._original;
expect(clone).to.eql(element);
});

it('should support props.children', () => {
let element = <foo children={<span>b</span>} />;
let clone = cloneElement(element);
delete clone._original;
delete element._original;
expect(clone).to.eql(element);
expect(cloneElement(clone).props.children).to.eql(element.props.children);
});
Expand All @@ -37,6 +42,8 @@ describe('compat cloneElement', () => {
</foo>
);
let clone = cloneElement(element);
delete clone._original;
delete element._original;
expect(clone).to.eql(element);
expect(clone.props.children.type).to.eql('div');
});
Expand Down
3 changes: 1 addition & 2 deletions jsx-runtime/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ function createVNode(type, props, key, __source, __self) {
_component: null,
_hydrating: null,
constructor: undefined,
_original: undefined,
_original: 0,
__source,
__self
};
vnode._original = vnode;

// If a Component VNode, check for and apply defaultProps.
// Note: `type` is often a String, and can be `undefined` in development.
Expand Down
2 changes: 1 addition & 1 deletion src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function renderComponent(component) {
if (parentDom) {
let commitQueue = [];
const oldVNode = assign({}, vnode);
oldVNode._original = {};
oldVNode._original = vnode._original + 1;

let newDom = diff(
parentDom,
Expand Down
6 changes: 6 additions & 0 deletions src/diff/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,12 @@ export function diff(
}

c._force = false;
} else if (
excessDomChildren == null &&
newVNode._original === oldVNode._original
) {
newVNode._children = oldVNode._children;
newVNode._dom = oldVNode._dom;
} else {
newVNode._dom = diffElementNodes(
oldVNode._dom,
Expand Down

0 comments on commit 378d989

Please sign in to comment.