@samitouri / QOS-React-2 / commits / 6c1592f384

Pass type to the relevant host config methods

Instead of reading it from the DOM node.

Sebastian Markbage committed Dec 13, 2016 at 14:37 UTC 6c1592f3842fb2bee94e82e84d64b17dec39b38b
6 files changed +19 -26
src/renderers/art/ReactARTFiber.js
+2 -2
@@ -408,7 +408,7 @@ const ARTRenderer = ReactFiberReconciler({
408 // Noop
409 },
410
411 - commitUpdate(instance, oldProps, newProps) {
411 + commitUpdate(instance, type, oldProps, newProps) {
412 instance._applyProps(instance, newProps, oldProps);
413 },
414
@@ -467,7 +467,7 @@ const ARTRenderer = ReactFiberReconciler({
467 // Noop
468 },
469
470 - prepareUpdate(domElement, oldProps, newProps) {
470 + prepareUpdate(domElement, type, oldProps, newProps) {
471 return true;
472 },
473
src/renderers/dom/fiber/ReactDOMFiber.js
+5 -14
@@ -97,20 +97,16 @@ var DOMRenderer = ReactFiberReconciler({
97
98 finalizeInitialChildren(
99 domElement : Instance,
100 + type : string,
101 props : Props,
102 rootContainerInstance : Container,
103 ) : 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);
105 },
106
107 prepareUpdate(
108 domElement : Instance,
109 + type : string,
110 oldProps : Props,
111 newProps : Props
112 ) : boolean {
@@ -119,21 +115,16 @@ var DOMRenderer = ReactFiberReconciler({
115
116 commitUpdate(
117 domElement : Instance,
118 + type : string,
119 oldProps : Props,
120 newProps : Props,
121 rootContainerInstance : Container,
122 internalInstanceHandle : Object,
123 ) : 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();
124 // Update the internal instance handle so that we know which props are
125 // the current ones.
126 precacheFiberNode(internalInstanceHandle, domElement);
136 - updateProperties(domElement, tag, oldProps, newProps, rootContainerInstance);
127 + updateProperties(domElement, type, oldProps, newProps, rootContainerInstance);
128 },
129
130 shouldSetTextContent(props : Props) : boolean {
src/renderers/noop/ReactNoop.js
+3 -3
@@ -60,15 +60,15 @@ var NoopRenderer = ReactFiberReconciler({
60 parentInstance.children.push(child);
61 },
62
63 - finalizeInitialChildren(domElement : Instance, props : Props) : void {
63 + finalizeInitialChildren(domElement : Instance, type : string, props : Props) : void {
64 // Noop
65 },
66
67 - prepareUpdate(instance : Instance, oldProps : Props, newProps : Props) : boolean {
67 + prepareUpdate(instance : Instance, type : string, oldProps : Props, newProps : Props) : boolean {
68 return true;
69 },
70
71 - commitUpdate(instance : Instance, oldProps : Props, newProps : Props) : void {
71 + commitUpdate(instance : Instance, type : string, oldProps : Props, newProps : Props) : void {
72 instance.prop = newProps.prop;
73 },
74
src/renderers/shared/fiber/ReactFiberCommitWork.js
+2 -1
@@ -373,7 +373,8 @@ module.exports = function<T, P, I, TI, C, CX>(
373 const newProps = finishedWork.memoizedProps;
374 const oldProps = current.memoizedProps;
375 const rootContainerInstance = getRootHostContainer();
376 - commitUpdate(instance, oldProps, newProps, rootContainerInstance, finishedWork);
376 + const type = finishedWork.type;
377 + commitUpdate(instance, type, oldProps, newProps, rootContainerInstance, finishedWork);
378 }
379 detachRefIfNeeded(current, finishedWork);
380 return;
src/renderers/shared/fiber/ReactFiberCompleteWork.js
+4 -3
@@ -215,6 +215,7 @@ module.exports = function<T, P, I, TI, C, CX>(
215 }
216 case HostComponent:
217 popHostContext(workInProgress);
218 + const type = workInProgress.type;
219 let newProps = workInProgress.pendingProps;
220 if (current && workInProgress.stateNode != null) {
221 // 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>(
229 newProps = workInProgress.memoizedProps || oldProps;
230 }
231 const instance : I = workInProgress.stateNode;
231 - if (prepareUpdate(instance, oldProps, newProps)) {
232 + if (prepareUpdate(instance, type, oldProps, newProps)) {
233 // This returns true if there was something to update.
234 markUpdate(workInProgress);
235 }
@@ -249,14 +250,14 @@ module.exports = function<T, P, I, TI, C, CX>(
250 // or completeWork depending on we want to add then top->down or
251 // bottom->up. Top->down is faster in IE11.
252 const instance = createInstance(
252 - workInProgress.type,
253 + type,
254 newProps,
255 rootContainerInstance,
256 currentHostContext,
257 workInProgress
258 );
259 appendAllChildren(instance, workInProgress);
259 - finalizeInitialChildren(instance, newProps, rootContainerInstance);
260 + finalizeInitialChildren(instance, type, newProps, rootContainerInstance);
261
262 workInProgress.stateNode = instance;
263 if (workInProgress.ref) {
src/renderers/shared/fiber/ReactFiberReconciler.js
+3 -3
@@ -46,10 +46,10 @@ export type HostConfig<T, P, I, TI, C, CX> = {
46
47 createInstance(type : T, props : P, rootContainerInstance : C, hostContext : CX | null, internalInstanceHandle : OpaqueNode) : I,
48 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,
50
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,
53
54 shouldSetTextContent(props : P) : boolean,
55 resetTextContent(instance : I) : void,