Skip to content

Commit d52b3ef

Browse files
committed
Remove replaceNode
1 parent 3ff5f50 commit d52b3ef

File tree

4 files changed

+30
-258
lines changed

4 files changed

+30
-258
lines changed

src/internal.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export interface PreactElement extends preact.ContainerNode {
9595
data?: CharacterData['data'];
9696
// Property to set __dangerouslySetInnerHTML
9797
innerHTML?: Element['innerHTML'];
98+
remove?: Element['remove'];
9899

99100
// Attribute reading and setting
100101
readonly attributes?: Element['attributes'];
@@ -110,6 +111,8 @@ export interface PreactElement extends preact.ContainerNode {
110111

111112
// nextSibling required for inserting nodes
112113
readonly nextSibling: ContainerNode | null;
114+
readonly firstChild: ContainerNode | null;
115+
113116

114117
// Used to match DOM nodes to VNodes during hydration. Note: doesn't exist
115118
// on Text nodes
@@ -162,7 +165,6 @@ export interface Component<P = {}, S = {}> extends preact.Component<P, S> {
162165
// When component is functional component, this is reset to functional component
163166
constructor: ComponentType<P>;
164167
state: S; // Override Component["state"] to not be readonly for internal use, specifically Hooks
165-
base?: PreactElement;
166168

167169
_dirty: boolean;
168170
_force?: boolean;

src/render.js

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

2727
// To be able to support calling `render()` multiple times on the same
2828
// DOM node, we need to obtain a reference to the previous tree. We do
2929
// this by assigning a new `_children` property to DOM nodes which points
3030
// to the last rendered tree. By default this property is not present, which
3131
// means that we are mounting a new tree for the first time.
32-
let oldVNode = isHydrating
33-
? null
34-
: (replaceNode && replaceNode._children) || parentDom._children;
32+
let oldVNode = isHydrating ? null : parentDom._children;
3533

36-
vnode = ((!isHydrating && replaceNode) || parentDom)._children =
37-
createElement(Fragment, null, [vnode]);
34+
vnode = parentDom._children = createElement(Fragment, null, [vnode]);
3835

3936
// List of effects that need to be called after diffing.
4037
let commitQueue = [],
@@ -47,19 +44,13 @@ export function render(vnode, parentDom, replaceNode) {
4744
oldVNode || EMPTY_OBJ,
4845
EMPTY_OBJ,
4946
parentDom.namespaceURI,
50-
!isHydrating && replaceNode
51-
? [replaceNode]
52-
: oldVNode
53-
? null
54-
: parentDom.firstChild
55-
? slice.call(parentDom.childNodes)
56-
: null,
47+
oldVNode
48+
? null
49+
: parentDom.firstChild
50+
? slice.call(parentDom.childNodes)
51+
: null,
5752
commitQueue,
58-
!isHydrating && replaceNode
59-
? replaceNode
60-
: oldVNode
61-
? oldVNode._dom
62-
: parentDom.firstChild,
53+
oldVNode ? oldVNode._dom : parentDom.firstChild,
6354
isHydrating,
6455
refQueue
6556
);

test/browser/replaceNode.test.js

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

v17.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Breaking changes
2+
3+
- The package now only exports ESM https://github.com/graphql/graphql-js/pull/3552
4+
- `GraphQLError` can now only be constructed with a message and options rather than also with positional arguments https://github.com/graphql/graphql-js/pull/3577
5+
- `createSourceEventStream` can now only be used with with an object-argument rather than alsow with positional arguments https://github.com/graphql/graphql-js/pull/3635
6+
- Allow `subscribe` to return a value rather than only a Promise, this makes the returned type in line with `execute` https://github.com/graphql/graphql-js/pull/3620
7+
- `execute` throws an error when it sees a `@defer` or `@stream` directive, use `experimentalExecuteIncrementally` instead https://github.com/graphql/graphql-js/pull/3722
8+
- Remove support for defer/stream from subscriptions, in case you have fragments that you use with `defer/stream` that end up in a subscription, use the `if` argument of the directive to disable it in your subscriptin operations https://github.com/graphql/graphql-js/pull/3742
9+
10+
## Removals
11+
12+
- Remove `graphql/subscription` module https://github.com/graphql/graphql-js/pull/3570
13+
- Remove `getOperationType` function https://github.com/graphql/graphql-js/pull/3571
14+
- Remove `getVisitFn` function https://github.com/graphql/graphql-js/pull/3580
15+
- Remove `printError` and `formatError` utils https://github.com/graphql/graphql-js/pull/3582
16+
- Remove `assertValidName` and `isValidNameError` utils https://github.com/graphql/graphql-js/pull/3572
17+
- Remove `assertValidExecutionArguments` function https://github.com/graphql/graphql-js/pull/3643
18+
- Remove `TokenKindEnum`, `KindEnum` and `DirectiveLocationEnum` types, use `Kind`, `TokenKind` and `DirectiveLocation` instead. https://github.com/graphql/graphql-js/pull/3579

0 commit comments

Comments
 (0)