Skip to content

Commit 4fe8287

Browse files
authored
remove _context from internal and move to data (#3832)
* remove _context from internal and move to data * fix render to string
1 parent ff28147 commit 4fe8287

File tree

6 files changed

+7
-10
lines changed

6 files changed

+7
-10
lines changed

server/src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ function _renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {
121121
} else {
122122
let rendered;
123123

124-
vnode._context = context;
125124
vnode.data = {
126-
_hooks: []
125+
_hooks: [],
126+
_context: context
127127
};
128128

129129
let c = (vnode._component = {

src/create-root.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function createRoot(parentDom) {
4747
}
4848
rootInternal.flags |= flags;
4949

50-
rootInternal._context = {};
50+
rootInternal.data._context = {};
5151

5252
mount(rootInternal, vnode, parentDom, firstChild);
5353
}

src/diff/mount.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ function mountComponent(internal, startDom) {
389389
c.state = c._nextState;
390390

391391
if (c.getChildContext != null) {
392-
internal._context = Object.assign({}, context, c.getChildContext());
392+
internal.data._context = Object.assign({}, context, c.getChildContext());
393393
}
394394

395395
if (renderResult == null) {

src/diff/patch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ function patchComponent(internal, newVNode) {
292292
c.state = c._nextState;
293293

294294
if (c.getChildContext != null) {
295-
internal._context = Object.assign({}, context, c.getChildContext());
295+
internal.data._context = Object.assign({}, context, c.getChildContext());
296296
}
297297

298298
if (ENABLE_CLASSES) {

src/internal.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ export interface Internal<P = {}> {
157157
*/
158158
/** The component instance for which this is a backing Internal node */
159159
_component: Component | null;
160-
/** most recent context object passed down to this Internal from its parent */
161-
_context: any;
162160
/** This Internal's distance from the tree root */
163161
_depth: number | null;
164162
/** Callbacks to invoke when this internal commits */

src/tree.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,14 @@ export function createInternal(vnode, parentInternal) {
8989
_prevRef: null,
9090
data:
9191
flags & TYPE_COMPONENT
92-
? { _commitCallbacks: [], _stateCallbacks: [] }
92+
? { _commitCallbacks: [], _context: null, _stateCallbacks: [] }
9393
: null,
9494
rerender: enqueueRender,
9595
flags,
9696
_children: null,
9797
_parent: parentInternal,
9898
_vnodeId: vnodeId,
9999
_component: null,
100-
_context: null,
101100
_depth: parentInternal ? parentInternal._depth + 1 : 0
102101
};
103102

@@ -175,7 +174,7 @@ export function getChildDom(internal, offset) {
175174
*/
176175
export function getParentContext(internal) {
177176
// @TODO: compare performance of recursion here (it's 11b smaller, but may be slower for deep trees)
178-
return internal._context || getParentContext(internal._parent);
177+
return internal.data._context || getParentContext(internal._parent);
179178

180179
// while ((internal = internal._parent)) {
181180
// let context = internal._context;

0 commit comments

Comments
 (0)