Skip to content

Commit 572cb0c

Browse files
committed
Pass type to the relevant host config methods
Instead of reading it from the DOM node.
1 parent 775f706 commit 572cb0c

File tree

6 files changed

+19
-26
lines changed

6 files changed

+19
-26
lines changed

src/renderers/art/ReactARTFiber.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ const ARTRenderer = ReactFiberReconciler({
408408
// Noop
409409
},
410410

411-
commitUpdate(instance, oldProps, newProps) {
411+
commitUpdate(instance, type, oldProps, newProps) {
412412
instance._applyProps(instance, newProps, oldProps);
413413
},
414414

@@ -467,7 +467,7 @@ const ARTRenderer = ReactFiberReconciler({
467467
// Noop
468468
},
469469

470-
prepareUpdate(domElement, oldProps, newProps) {
470+
prepareUpdate(domElement, type, oldProps, newProps) {
471471
return true;
472472
},
473473

src/renderers/dom/fiber/ReactDOMFiber.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,16 @@ var DOMRenderer = ReactFiberReconciler({
9797

9898
finalizeInitialChildren(
9999
domElement : Instance,
100+
type : string,
100101
props : Props,
101102
rootContainerInstance : Container,
102103
) : void {
103-
// TODO: we normalize here because DOM renderer expects tag to be lowercase.
104-
// We can change DOM renderer to compare special case against upper case,
105-
// and use tagName (which is upper case for HTML DOM elements). Or we could
106-
// let the renderer "normalize" the fiber type so we don't have to read
107-
// the type from DOM. However we need to remember SVG is case-sensitive.
108-
var tag = domElement.tagName.toLowerCase();
109-
setInitialProperties(domElement, tag, props, rootContainerInstance);
104+
setInitialProperties(domElement, type, props, rootContainerInstance);
110105
},
111106

112107
prepareUpdate(
113108
domElement : Instance,
109+
type : string,
114110
oldProps : Props,
115111
newProps : Props
116112
) : boolean {
@@ -119,21 +115,16 @@ var DOMRenderer = ReactFiberReconciler({
119115

120116
commitUpdate(
121117
domElement : Instance,
118+
type : string,
122119
oldProps : Props,
123120
newProps : Props,
124121
rootContainerInstance : Container,
125122
internalInstanceHandle : Object,
126123
) : void {
127-
// TODO: we normalize here because DOM renderer expects tag to be lowercase.
128-
// We can change DOM renderer to compare special case against upper case,
129-
// and use tagName (which is upper case for HTML DOM elements). Or we could
130-
// let the renderer "normalize" the fiber type so we don't have to read
131-
// the type from DOM. However we need to remember SVG is case-sensitive.
132-
var tag = domElement.tagName.toLowerCase();
133124
// Update the internal instance handle so that we know which props are
134125
// the current ones.
135126
precacheFiberNode(internalInstanceHandle, domElement);
136-
updateProperties(domElement, tag, oldProps, newProps, rootContainerInstance);
127+
updateProperties(domElement, type, oldProps, newProps, rootContainerInstance);
137128
},
138129

139130
shouldSetTextContent(props : Props) : boolean {

src/renderers/noop/ReactNoop.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ var NoopRenderer = ReactFiberReconciler({
6060
parentInstance.children.push(child);
6161
},
6262

63-
finalizeInitialChildren(domElement : Instance, props : Props) : void {
63+
finalizeInitialChildren(domElement : Instance, type : string, props : Props) : void {
6464
// Noop
6565
},
6666

67-
prepareUpdate(instance : Instance, oldProps : Props, newProps : Props) : boolean {
67+
prepareUpdate(instance : Instance, type : string, oldProps : Props, newProps : Props) : boolean {
6868
return true;
6969
},
7070

71-
commitUpdate(instance : Instance, oldProps : Props, newProps : Props) : void {
71+
commitUpdate(instance : Instance, type : string, oldProps : Props, newProps : Props) : void {
7272
instance.prop = newProps.prop;
7373
},
7474

src/renderers/shared/fiber/ReactFiberCommitWork.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,8 @@ module.exports = function<T, P, I, TI, C, CX>(
373373
const newProps = finishedWork.memoizedProps;
374374
const oldProps = current.memoizedProps;
375375
const rootContainerInstance = getRootHostContainer();
376-
commitUpdate(instance, oldProps, newProps, rootContainerInstance, finishedWork);
376+
const type = finishedWork.type;
377+
commitUpdate(instance, type, oldProps, newProps, rootContainerInstance, finishedWork);
377378
}
378379
detachRefIfNeeded(current, finishedWork);
379380
return;

src/renderers/shared/fiber/ReactFiberCompleteWork.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ module.exports = function<T, P, I, TI, C, CX>(
215215
}
216216
case HostComponent:
217217
popHostContext(workInProgress);
218+
const type = workInProgress.type;
218219
let newProps = workInProgress.pendingProps;
219220
if (current && workInProgress.stateNode != null) {
220221
// If we have an alternate, that means this is an update and we need to
@@ -228,7 +229,7 @@ module.exports = function<T, P, I, TI, C, CX>(
228229
newProps = workInProgress.memoizedProps || oldProps;
229230
}
230231
const instance : I = workInProgress.stateNode;
231-
if (prepareUpdate(instance, oldProps, newProps)) {
232+
if (prepareUpdate(instance, type, oldProps, newProps)) {
232233
// This returns true if there was something to update.
233234
markUpdate(workInProgress);
234235
}
@@ -249,14 +250,14 @@ module.exports = function<T, P, I, TI, C, CX>(
249250
// or completeWork depending on we want to add then top->down or
250251
// bottom->up. Top->down is faster in IE11.
251252
const instance = createInstance(
252-
workInProgress.type,
253+
type,
253254
newProps,
254255
rootContainerInstance,
255256
currentHostContext,
256257
workInProgress
257258
);
258259
appendAllChildren(instance, workInProgress);
259-
finalizeInitialChildren(instance, newProps, rootContainerInstance);
260+
finalizeInitialChildren(instance, type, newProps, rootContainerInstance);
260261

261262
workInProgress.stateNode = instance;
262263
if (workInProgress.ref) {

src/renderers/shared/fiber/ReactFiberReconciler.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ export type HostConfig<T, P, I, TI, C, CX> = {
4646

4747
createInstance(type : T, props : P, rootContainerInstance : C, hostContext : CX | null, internalInstanceHandle : OpaqueNode) : I,
4848
appendInitialChild(parentInstance : I, child : I | TI) : void,
49-
finalizeInitialChildren(parentInstance : I, props : P, rootContainerInstance : C) : void,
49+
finalizeInitialChildren(parentInstance : I, type : T, props : P, rootContainerInstance : C) : void,
5050

51-
prepareUpdate(instance : I, oldProps : P, newProps : P) : boolean,
52-
commitUpdate(instance : I, oldProps : P, newProps : P, rootContainerInstance : C, internalInstanceHandle : OpaqueNode) : void,
51+
prepareUpdate(instance : I, type : T, oldProps : P, newProps : P) : boolean,
52+
commitUpdate(instance : I, type : T, oldProps : P, newProps : P, rootContainerInstance : C, internalInstanceHandle : OpaqueNode) : void,
5353

5454
shouldSetTextContent(props : P) : boolean,
5555
resetTextContent(instance : I) : void,

0 commit comments

Comments
 (0)