Skip to content

Commit 63200de

Browse files
committed
Golf
1 parent 323d0d9 commit 63200de

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/diff/index.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -555,15 +555,13 @@ function diffElementNodes(
555555
);
556556

557557
// Remove children that are not part of any vnode.
558-
if (excessDomChildren != NULL) {
558+
if (
559+
excessDomChildren != NULL &&
560+
newVNode.type != 'body' &&
561+
newVNode.type != 'head'
562+
) {
559563
for (i = excessDomChildren.length; i--; ) {
560-
const nodeName =
561-
excessDomChildren[i] &&
562-
excessDomChildren[i].parentNode &&
563-
excessDomChildren[i].parentNode.localName;
564-
565-
if (nodeName != 'head' && nodeName != 'body')
566-
removeNode(excessDomChildren[i]);
564+
removeNode(excessDomChildren[i]);
567565
}
568566
}
569567
}

test/browser/render.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,6 +1969,7 @@ describe('render()', () => {
19691969

19701970
it('should work with document', () => {
19711971
document.textContent = '';
1972+
document.body.textContent = '';
19721973
const App = () => (
19731974
<Fragment>
19741975
<head>

0 commit comments

Comments
 (0)