@@ -16,7 +16,6 @@ import type {
16
16
Props ,
17
17
Container ,
18
18
ChildSet ,
19
- HostContext ,
20
19
} from './ReactFiberHostConfig' ;
21
20
22
21
import {
@@ -51,10 +50,8 @@ import {
51
50
import invariant from 'shared/invariant' ;
52
51
53
52
import {
54
- getRootHostContext ,
55
53
createInstance ,
56
54
createTextInstance ,
57
- createHiddenTextInstance ,
58
55
appendInitialChild ,
59
56
finalizeInitialChildren ,
60
57
prepareUpdate ,
@@ -63,6 +60,8 @@ import {
63
60
cloneInstance ,
64
61
cloneHiddenInstance ,
65
62
cloneUnhiddenInstance ,
63
+ cloneHiddenTextInstance ,
64
+ cloneUnhiddenTextInstance ,
66
65
createContainerChildSet ,
67
66
appendChildToContainerChildSet ,
68
67
finalizeContainerChildren ,
@@ -107,8 +106,6 @@ if (supportsMutation) {
107
106
appendAllChildren = function (
108
107
parent : Instance ,
109
108
workInProgress : Fiber ,
110
- rootContainerInstance : Container ,
111
- childHostContext : HostContext ,
112
109
needsVisibilityToggle : boolean ,
113
110
isHidden : boolean ,
114
111
) {
@@ -141,11 +138,7 @@ if (supportsMutation) {
141
138
}
142
139
} ;
143
140
144
- updateHostContainer = function (
145
- workInProgress : Fiber ,
146
- rootContainerInstance : Container ,
147
- childHostContext : HostContext ,
148
- ) {
141
+ updateHostContainer = function ( workInProgress : Fiber ) {
149
142
// Noop
150
143
} ;
151
144
updateHostComponent = function (
@@ -154,7 +147,6 @@ if (supportsMutation) {
154
147
type : Type ,
155
148
newProps : Props ,
156
149
rootContainerInstance : Container ,
157
- childHostContext : HostContext ,
158
150
) {
159
151
// If we have an alternate, that means this is an update and we need to
160
152
// schedule a side-effect to do the updates.
@@ -207,8 +199,6 @@ if (supportsMutation) {
207
199
appendAllChildren = function (
208
200
parent : Instance ,
209
201
workInProgress : Fiber ,
210
- rootContainerInstance : Container ,
211
- childHostContext : HostContext ,
212
202
needsVisibilityToggle : boolean ,
213
203
isHidden : boolean ,
214
204
) {
@@ -239,19 +229,9 @@ if (supportsMutation) {
239
229
if ( needsVisibilityToggle ) {
240
230
const text = node . memoizedProps ;
241
231
if ( isHidden ) {
242
- instance = createHiddenTextInstance (
243
- text ,
244
- rootContainerInstance ,
245
- childHostContext ,
246
- workInProgress ,
247
- ) ;
232
+ instance = cloneHiddenTextInstance ( instance , text , node ) ;
248
233
} else {
249
- instance = createTextInstance (
250
- text ,
251
- rootContainerInstance ,
252
- childHostContext ,
253
- workInProgress ,
254
- ) ;
234
+ instance = cloneUnhiddenTextInstance ( instance , text , node ) ;
255
235
}
256
236
node . stateNode = instance ;
257
237
}
@@ -267,27 +247,13 @@ if (supportsMutation) {
267
247
if ( newIsHidden ) {
268
248
const primaryChildParent = node . child ;
269
249
if ( primaryChildParent !== null ) {
270
- appendAllChildren (
271
- parent ,
272
- primaryChildParent ,
273
- rootContainerInstance ,
274
- childHostContext ,
275
- true ,
276
- newIsHidden ,
277
- ) ;
250
+ appendAllChildren ( parent , primaryChildParent , true , newIsHidden ) ;
278
251
node = primaryChildParent . sibling ;
279
252
continue ;
280
253
}
281
254
} else {
282
255
const primaryChildParent = node ;
283
- appendAllChildren (
284
- parent ,
285
- primaryChildParent ,
286
- rootContainerInstance ,
287
- childHostContext ,
288
- true ,
289
- newIsHidden ,
290
- ) ;
256
+ appendAllChildren ( parent , primaryChildParent , true , newIsHidden ) ;
291
257
// eslint-disable-next-line no-labels
292
258
break branches;
293
259
}
@@ -323,8 +289,6 @@ if (supportsMutation) {
323
289
const appendAllChildrenToContainer = function (
324
290
containerChildSet : ChildSet ,
325
291
workInProgress : Fiber ,
326
- rootContainerInstance : Container ,
327
- rootHostContext : HostContext ,
328
292
needsVisibilityToggle : boolean ,
329
293
isHidden : boolean ,
330
294
) {
@@ -355,19 +319,9 @@ if (supportsMutation) {
355
319
if ( needsVisibilityToggle ) {
356
320
const text = node . memoizedProps ;
357
321
if ( isHidden ) {
358
- instance = createHiddenTextInstance (
359
- text ,
360
- rootContainerInstance ,
361
- rootHostContext ,
362
- workInProgress ,
363
- ) ;
322
+ instance = cloneHiddenTextInstance ( instance , text , node ) ;
364
323
} else {
365
- instance = createTextInstance (
366
- text ,
367
- rootContainerInstance ,
368
- rootHostContext ,
369
- workInProgress ,
370
- ) ;
324
+ instance = cloneUnhiddenTextInstance ( instance , text , node ) ;
371
325
}
372
326
node . stateNode = instance ;
373
327
}
@@ -386,8 +340,6 @@ if (supportsMutation) {
386
340
appendAllChildrenToContainer (
387
341
containerChildSet ,
388
342
primaryChildParent ,
389
- rootContainerInstance ,
390
- rootHostContext ,
391
343
true ,
392
344
newIsHidden ,
393
345
) ;
@@ -399,8 +351,6 @@ if (supportsMutation) {
399
351
appendAllChildrenToContainer (
400
352
containerChildSet ,
401
353
primaryChildParent ,
402
- rootContainerInstance ,
403
- rootHostContext ,
404
354
true ,
405
355
newIsHidden ,
406
356
) ;
@@ -434,11 +384,7 @@ if (supportsMutation) {
434
384
node = node . sibling ;
435
385
}
436
386
} ;
437
- updateHostContainer = function (
438
- workInProgress : Fiber ,
439
- rootContainerInstance : Container ,
440
- rootHostContext : HostContext ,
441
- ) {
387
+ updateHostContainer = function ( workInProgress : Fiber ) {
442
388
const portalOrRoot : {
443
389
containerInfo : Container ,
444
390
pendingChildren : ChildSet ,
@@ -451,14 +397,7 @@ if (supportsMutation) {
451
397
const container = portalOrRoot . containerInfo ;
452
398
let newChildSet = createContainerChildSet ( container ) ;
453
399
// If children might have changed, we have to add them all to the set.
454
- appendAllChildrenToContainer (
455
- newChildSet ,
456
- workInProgress ,
457
- rootContainerInstance ,
458
- rootHostContext ,
459
- false ,
460
- false ,
461
- ) ;
400
+ appendAllChildrenToContainer ( newChildSet , workInProgress , false , false ) ;
462
401
portalOrRoot . pendingChildren = newChildSet ;
463
402
// Schedule an update on the container to swap out the container.
464
403
markUpdate ( workInProgress ) ;
@@ -471,7 +410,6 @@ if (supportsMutation) {
471
410
type : Type ,
472
411
newProps : Props ,
473
412
rootContainerInstance : Container ,
474
- childHostContext : HostContext ,
475
413
) {
476
414
const currentInstance = current . stateNode ;
477
415
const oldProps = current . memoizedProps ;
@@ -532,14 +470,7 @@ if (supportsMutation) {
532
470
markUpdate ( workInProgress ) ;
533
471
} else {
534
472
// If children might have changed, we have to add them all to the set.
535
- appendAllChildren (
536
- newInstance ,
537
- workInProgress ,
538
- rootContainerInstance ,
539
- childHostContext ,
540
- false ,
541
- false ,
542
- ) ;
473
+ appendAllChildren ( newInstance , workInProgress , false , false ) ;
543
474
}
544
475
} ;
545
476
updateHostText = function (
@@ -565,11 +496,7 @@ if (supportsMutation) {
565
496
} ;
566
497
} else {
567
498
// No host operations
568
- updateHostContainer = function (
569
- workInProgress : Fiber ,
570
- rootContainerInstance : Container ,
571
- hostContext : HostContext ,
572
- ) {
499
+ updateHostContainer = function ( workInProgress : Fiber ) {
573
500
// Noop
574
501
} ;
575
502
updateHostComponent = function (
@@ -578,7 +505,6 @@ if (supportsMutation) {
578
505
type : Type ,
579
506
newProps : Props ,
580
507
rootContainerInstance : Container ,
581
- childHostContext : HostContext ,
582
508
) {
583
509
// Noop
584
510
} ;
@@ -630,19 +556,12 @@ function completeWork(
630
556
// TODO: Delete this when we delete isMounted and findDOMNode.
631
557
workInProgress . effectTag &= ~ Placement ;
632
558
}
633
- const rootContainerInstance = fiberRoot . containerInfo ;
634
- const rootHostContext = getRootHostContext ( rootContainerInstance ) ;
635
- updateHostContainer (
636
- workInProgress ,
637
- rootContainerInstance ,
638
- rootHostContext ,
639
- ) ;
559
+ updateHostContainer ( workInProgress ) ;
640
560
break ;
641
561
}
642
562
case HostComponent : {
643
- const rootContainerInstance = getRootHostContainer ( ) ;
644
- const childHostContext = getHostContext ( ) ;
645
563
popHostContext ( workInProgress ) ;
564
+ const rootContainerInstance = getRootHostContainer ( ) ;
646
565
const type = workInProgress . type ;
647
566
if ( current !== null && workInProgress . stateNode != null ) {
648
567
updateHostComponent (
@@ -651,7 +570,6 @@ function completeWork(
651
570
type ,
652
571
newProps ,
653
572
rootContainerInstance ,
654
- childHostContext ,
655
573
) ;
656
574
657
575
if ( current . ref !== workInProgress . ref ) {
@@ -697,14 +615,7 @@ function completeWork(
697
615
workInProgress ,
698
616
) ;
699
617
700
- appendAllChildren (
701
- instance ,
702
- workInProgress ,
703
- rootContainerInstance ,
704
- childHostContext ,
705
- false ,
706
- false ,
707
- ) ;
618
+ appendAllChildren ( instance , workInProgress , false , false ) ;
708
619
709
620
// Certain renderers require commit-time effects for initial mount.
710
621
// (eg DOM renderer supports auto-focus for certain elements).
@@ -818,14 +729,8 @@ function completeWork(
818
729
case Profiler :
819
730
break ;
820
731
case HostPortal :
821
- const rootContainerInstance = getRootHostContainer ( ) ;
822
- const childHostContext = getHostContext ( ) ;
823
732
popHostContainer ( workInProgress ) ;
824
- updateHostContainer (
825
- workInProgress ,
826
- rootContainerInstance ,
827
- childHostContext ,
828
- ) ;
733
+ updateHostContainer ( workInProgress ) ;
829
734
break ;
830
735
case ContextProvider :
831
736
// Pop provider fiber
0 commit comments