Skip to content

Commit

Permalink
Fix edge case with wrong children normalizing
Browse files Browse the repository at this point in the history
  • Loading branch information
dfilatov committed Dec 10, 2019
1 parent fc299ab commit 48eb094
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions spec/normalizeNode/normalizeNode.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ describe('normalizeNode', () => {
.to.be.eql(node);
});

it('should not modify array child', () => {
const child = [h('a')];

normalizeNode([child, h('b')]);

expect(child).to.have.length(1);
});

it('should reuse existing array if possible', () => {
const children = [h('a'), h('b')];

Expand Down
2 changes: 1 addition & 1 deletion src/nodes/utils/normalizeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function normalizeNode(obj) {
(res === obj?
res.slice(0, i) :
Array.isArray(res)? res : [nodeToElement(res)]).concat(child) :
child;
child.slice();
}
else if(res !== obj) {
if(!hasContentBefore) {
Expand Down

0 comments on commit 48eb094

Please sign in to comment.