Skip to content

Commit e2988ca

Browse files
committed
Remove replaceNode
1 parent 0fc547c commit e2988ca

File tree

3 files changed

+10
-257
lines changed

3 files changed

+10
-257
lines changed

src/internal.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ declare global {
109109

110110
// nextSibling required for inserting nodes
111111
readonly nextSibling: ContainerNode | null;
112+
readonly firstChild: ContainerNode | null;
112113

113114
// Used to match DOM nodes to VNodes during hydration. Note: doesn't exist
114115
// on Text nodes

src/render.js

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,16 @@ export function render(vnode, parentDom, replaceNode) {
1717
// We abuse the `replaceNode` parameter in `hydrate()` to signal if we are in
1818
// hydration mode or not by passing the `hydrate` function instead of a DOM
1919
// element..
20-
let isHydrating = typeof replaceNode == 'function';
20+
let isHydrating = replaceNode === hydrate;
2121

2222
// To be able to support calling `render()` multiple times on the same
2323
// DOM node, we need to obtain a reference to the previous tree. We do
2424
// this by assigning a new `_children` property to DOM nodes which points
2525
// to the last rendered tree. By default this property is not present, which
2626
// means that we are mounting a new tree for the first time.
27-
let oldVNode = isHydrating
28-
? null
29-
: (replaceNode && replaceNode._children) || parentDom._children;
27+
let oldVNode = isHydrating ? null : parentDom._children;
3028

31-
vnode = ((!isHydrating && replaceNode) || parentDom)._children =
32-
createElement(Fragment, null, [vnode]);
29+
vnode = parentDom._children = createElement(Fragment, null, [vnode]);
3330

3431
// List of effects that need to be called after diffing.
3532
let commitQueue = [],
@@ -42,19 +39,13 @@ export function render(vnode, parentDom, replaceNode) {
4239
oldVNode || EMPTY_OBJ,
4340
EMPTY_OBJ,
4441
parentDom.namespaceURI,
45-
!isHydrating && replaceNode
46-
? [replaceNode]
47-
: oldVNode
48-
? null
49-
: parentDom.firstChild
50-
? slice.call(parentDom.childNodes)
51-
: null,
42+
oldVNode
43+
? null
44+
: parentDom.firstChild
45+
? slice.call(parentDom.childNodes)
46+
: null,
5247
commitQueue,
53-
!isHydrating && replaceNode
54-
? replaceNode
55-
: oldVNode
56-
? oldVNode._dom
57-
: parentDom.firstChild,
48+
oldVNode ? oldVNode._dom : parentDom.firstChild,
5849
isHydrating,
5950
refQueue
6051
);

test/browser/replaceNode.test.js

Lines changed: 0 additions & 239 deletions
This file was deleted.

0 commit comments

Comments
 (0)