Update the internal Fiber on the DOM node to always be the current
We need this to safely extract the current event listeners from the props. Unfortunately, we are still not safe to use the return pointer since it may not point to the current tree when the Fiber is reused. So this is not fully done yet.
Sebastian Markbage committed
Nov 20, 2016 at 17:14 UTC
075f3043a7959934a273a9f18327f36f1f324757
8 files changed
+34
-26
scripts/fiber/tests-failing.txt
-15
@@ -24,21 +24,6 @@ src/renderers/art/__tests__/ReactART-test.js
24
* resolves refs before componentDidMount
25
* resolves refs before componentDidUpdate
26
27
-src/renderers/dom/shared/__tests__/ReactBrowserEventEmitter-test.js
28
-* should store a listener correctly
29
-* should retrieve a listener correctly
30
-* should clear all handlers when asked to
31
-* should invoke a simple handler registered on a node
32
-* should not invoke handlers if ReactBrowserEventEmitter is disabled
33
-* should bubble simply
34
-* should continue bubbling if an error is thrown
35
-* should set currentTarget
36
-* should not stopPropagation if false is returned
37
-* should have mouse enter simulated by test utils
38
-* should infer onTouchTap from a touchStart/End
39
-* should infer onTouchTap from when dragging below threshold
40
-* should bubble onTouchTap
41
-
27
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
28
* should update styles when mutating style object
29
* should warn when mutating style
scripts/fiber/tests-passing-except-dev.txt
+6
@@ -131,9 +131,15 @@ src/renderers/shared/hooks/__tests__/ReactHostOperationHistoryHook-test.js
131
* gets recorded for composite roots
132
* gets recorded when a native is mounted deeply instead of null
133
* gets recorded during mount
134
+* gets recorded during an update
135
+* gets ignored if the styles are shallowly equal
136
* gets recorded during mount
137
+* gets recorded during an update
138
+* gets recorded as a removal during an update
139
* gets recorded during mount
140
+* gets recorded during an update
141
* gets recorded during mount
142
+* gets recorded during an update
143
* gets recorded during an update from text content
144
* gets recorded during an update from html
145
* gets recorded during an update from children
scripts/fiber/tests-passing.txt
+13
-6
@@ -534,14 +534,27 @@ src/renderers/dom/shared/__tests__/DOMPropertyOperations-test.js
534
* should support custom attributes
535
536
src/renderers/dom/shared/__tests__/ReactBrowserEventEmitter-test.js
537
+* should store a listener correctly
538
+* should retrieve a listener correctly
539
+* should clear all handlers when asked to
540
+* should invoke a simple handler registered on a node
541
+* should not invoke handlers if ReactBrowserEventEmitter is disabled
542
+* should bubble simply
543
+* should continue bubbling if an error is thrown
544
+* should set currentTarget
545
* should support stopPropagation()
546
* should stop after first dispatch if stopPropagation
547
+* should not stopPropagation if false is returned
548
* should invoke handlers that were removed while bubbling
549
* should not invoke newly inserted handlers while bubbling
550
+* should have mouse enter simulated by test utils
551
+* should infer onTouchTap from a touchStart/End
552
+* should infer onTouchTap from when dragging below threshold
553
* should not onTouchTap from when dragging beyond threshold
554
* should listen to events only once
555
* should work with event plugins without dependencies
556
* should work with event plugins with dependencies
557
+* should bubble onTouchTap
558
* should not crash ensureScrollValueMonitoring when createEvent returns null
559
560
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
@@ -1160,12 +1173,6 @@ src/renderers/shared/hooks/__tests__/ReactComponentTreeHook-test.native.js
1173
1174
src/renderers/shared/hooks/__tests__/ReactHostOperationHistoryHook-test.js
1175
* gets ignored for composite roots that return null
1163
-* gets recorded during an update
1164
-* gets ignored if the styles are shallowly equal
1165
-* gets recorded during an update
1166
-* gets recorded as a removal during an update
1167
-* gets recorded during an update
1168
-* gets recorded during an update
1176
* gets ignored if new text is equal
1177
* gets ignored if new text is equal
1178
* gets ignored if the type has not changed
src/renderers/dom/fiber/ReactDOMFiber.js
+9
-1
@@ -104,9 +104,17 @@ var DOMRenderer = ReactFiberReconciler({
104
return true;
105
},
106
107
- commitUpdate(domElement : Instance, oldProps : Props, newProps : Props) : void {
107
+ commitUpdate(
108
+ domElement : Instance,
109
+ oldProps : Props,
110
+ newProps : Props,
111
+ internalInstanceHandle : Object
112
+ ) : void {
113
var type = domElement.tagName.toLowerCase(); // HACK
114
var root = document.body; // HACK
115
+ // Update the internal instance handle so that we know which props are
116
+ // the current ones.
117
+ precacheFiberNode(internalInstanceHandle, domElement);
118
updateProperties(domElement, type, oldProps, newProps, root);
119
},
120
src/renderers/dom/fiber/wrappers/ReactDOMFiberInput.js
-1
@@ -293,7 +293,6 @@ function updateNamedCousins(rootNode, props) {
293
// That's probably okay; we don't support it just as we don't support
294
// mixing React radio buttons with non-React ones.
295
var otherInstance = ReactDOMComponentTree.getInstanceFromNode(otherNode);
296
- // TODO: Ensure that otherInstance is the current Fiber instead of wip.
296
invariant(
297
otherInstance,
298
'ReactDOMInput: Mixing React and non-React radio inputs with the ' +
src/renderers/shared/fiber/ReactFiberCommitWork.js
+1
-1
@@ -282,7 +282,7 @@ module.exports = function<T, P, I, TI, C>(
282
// Commit the work prepared earlier.
283
const newProps = finishedWork.memoizedProps;
284
const oldProps = current.memoizedProps;
285
- commitUpdate(instance, oldProps, newProps);
285
+ commitUpdate(instance, oldProps, newProps, finishedWork);
286
}
287
detachRefIfNeeded(current, finishedWork);
288
return;
src/renderers/shared/fiber/ReactFiberReconciler.js
+1
-1
@@ -54,7 +54,7 @@ export type HostConfig<T, P, I, TI, C> = {
54
55
createInstance(type : T, props : P, children : HostChildren<I | TI>, internalInstanceHandle : OpaqueNode) : I,
56
prepareUpdate(instance : I, oldProps : P, newProps : P) : boolean,
57
- commitUpdate(instance : I, oldProps : P, newProps : P) : void,
57
+ commitUpdate(instance : I, oldProps : P, newProps : P, internalInstanceHandle : OpaqueNode) : void,
58
59
createTextInstance(text : string, internalInstanceHandle : OpaqueNode) : TI,
60
commitTextUpdate(textInstance : TI, oldText : string, newText : string) : void,
src/renderers/shared/shared/event/EventPluginHub.js
+4
-1
@@ -127,7 +127,10 @@ var EventPluginHub = {
127
// live here; needs to be moved to a better place soon
128
if (typeof inst.tag === 'number') {
129
// TODO: This is not safe because we might want the *other* Fiber's
130
- // props depending on which is the current one.
130
+ // props depending on which is the current one. This will usually be the
131
+ // current Fiber but if we're walking up the tree using TreeTraversal for
132
+ // bubbling, we will not be guaranteed to walk up the current tree when
133
+ // a Fiber has been reused.
134
const props = inst.memoizedProps;
135
listener = props[registrationName];
136
if (shouldPreventMouseEvent(registrationName, inst.type, props)) {