Skip to content

Commit 6ae87cf

Browse files
committed
Diff ReactDOMFiber properties in prepareUpdate
We now take advantage of the new capability to diff properties early. We do this by generating an update payload in the form of an array with each property name and value that we're about to update.
1 parent 0df97a4 commit 6ae87cf

File tree

2 files changed

+214
-112
lines changed

2 files changed

+214
-112
lines changed

src/renderers/dom/fiber/ReactDOMFiber.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var {
3535
createElement,
3636
getChildNamespace,
3737
setInitialProperties,
38+
diffProperties,
3839
updateProperties,
3940
} = ReactDOMFiberComponent;
4041
var { precacheFiberNode } = ReactDOMComponentTree;
@@ -203,7 +204,7 @@ var DOMRenderer = ReactFiberReconciler({
203204
newProps : Props,
204205
rootContainerInstance : Container,
205206
hostContext : HostContext,
206-
) : null | Object {
207+
) : null | Array<mixed> {
207208
if (__DEV__) {
208209
const hostContextDev = ((hostContext : any) : HostContextDev);
209210
if (typeof newProps.children !== typeof oldProps.children && (
@@ -214,7 +215,7 @@ var DOMRenderer = ReactFiberReconciler({
214215
validateDOMNesting(null, String(newProps.children), null, ownAncestorInfo);
215216
}
216217
}
217-
return {};
218+
return diffProperties(domElement, type, oldProps, newProps, rootContainerInstance);
218219
},
219220

220221
commitMount(
@@ -231,18 +232,17 @@ var DOMRenderer = ReactFiberReconciler({
231232

232233
commitUpdate(
233234
domElement : Instance,
234-
updatePayload : Object,
235+
updatePayload : Array<mixed>,
235236
type : string,
236237
oldProps : Props,
237238
newProps : Props,
238239
internalInstanceHandle : Object,
239240
) : void {
240241
// Update the internal instance handle so that we know which props are
241242
// the current ones.
242-
// TODO: Fix this hack.
243-
var rootContainerInstance = (domElement : any);
244243
precacheFiberNode(internalInstanceHandle, domElement);
245-
updateProperties(domElement, type, oldProps, newProps, rootContainerInstance);
244+
// Apply the diff to the DOM node.
245+
updateProperties(domElement, updatePayload, type, oldProps, newProps);
246246
},
247247

248248
shouldSetTextContent(props : Props) : boolean {

0 commit comments

Comments
 (0)