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.
This commit is contained in:
Sebastian Markbage committed 2016-11-22 16:16:45 -08:00
1 parent 7149a26eba
commit 075f3043a7
8 files changed
+34 -26

No files matched your search

-15
View File
@@ -24,21 +24,6 @@ src/renderers/art/__tests__/ReactART-test.js
* resolves refs before componentDidMount
* resolves refs before componentDidUpdate
src/renderers/dom/shared/__tests__/ReactBrowserEventEmitter-test.js
* should store a listener correctly
* should retrieve a listener correctly
* should clear all handlers when asked to
* should invoke a simple handler registered on a node
* should not invoke handlers if ReactBrowserEventEmitter is disabled
* should bubble simply
* should continue bubbling if an error is thrown
* should set currentTarget
* should not stopPropagation if false is returned
* should have mouse enter simulated by test utils
* should infer onTouchTap from a touchStart/End
* should infer onTouchTap from when dragging below threshold
* should bubble onTouchTap
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
* should update styles when mutating style object
* should warn when mutating style
@@ -131,9 +131,15 @@ src/renderers/shared/hooks/__tests__/ReactHostOperationHistoryHook-test.js
* gets recorded for composite roots
* gets recorded when a native is mounted deeply instead of null
* gets recorded during mount
* gets recorded during an update
* gets ignored if the styles are shallowly equal
* gets recorded during mount
* gets recorded during an update
* gets recorded as a removal during an update
* gets recorded during mount
* gets recorded during an update
* gets recorded during mount
* gets recorded during an update
* gets recorded during an update from text content
* gets recorded during an update from html
* gets recorded during an update from children
+13 -6
View File
@@ -534,14 +534,27 @@ src/renderers/dom/shared/__tests__/DOMPropertyOperations-test.js
* should support custom attributes
src/renderers/dom/shared/__tests__/ReactBrowserEventEmitter-test.js
* should store a listener correctly
* should retrieve a listener correctly
* should clear all handlers when asked to
* should invoke a simple handler registered on a node
* should not invoke handlers if ReactBrowserEventEmitter is disabled
* should bubble simply
* should continue bubbling if an error is thrown
* should set currentTarget
* should support stopPropagation()
* should stop after first dispatch if stopPropagation
* should not stopPropagation if false is returned
* should invoke handlers that were removed while bubbling
* should not invoke newly inserted handlers while bubbling
* should have mouse enter simulated by test utils
* should infer onTouchTap from a touchStart/End
* should infer onTouchTap from when dragging below threshold
* should not onTouchTap from when dragging beyond threshold
* should listen to events only once
* should work with event plugins without dependencies
* should work with event plugins with dependencies
* should bubble onTouchTap
* should not crash ensureScrollValueMonitoring when createEvent returns null
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
@@ -1160,12 +1173,6 @@ src/renderers/shared/hooks/__tests__/ReactComponentTreeHook-test.native.js
src/renderers/shared/hooks/__tests__/ReactHostOperationHistoryHook-test.js
* gets ignored for composite roots that return null
* gets recorded during an update
* gets ignored if the styles are shallowly equal
* gets recorded during an update
* gets recorded as a removal during an update
* gets recorded during an update
* gets recorded during an update
* gets ignored if new text is equal
* gets ignored if new text is equal
* gets ignored if the type has not changed
+9 -1
View File
@@ -104,9 +104,17 @@ var DOMRenderer = ReactFiberReconciler({
return true;
},
commitUpdate(domElement : Instance, oldProps : Props, newProps : Props) : void {
commitUpdate(
domElement : Instance,
oldProps : Props,
newProps : Props,
internalInstanceHandle : Object
) : void {
var type = domElement.tagName.toLowerCase(); // HACK
var root = document.body; // HACK
// Update the internal instance handle so that we know which props are
// the current ones.
precacheFiberNode(internalInstanceHandle, domElement);
updateProperties(domElement, type, oldProps, newProps, root);
},
@@ -293,7 +293,6 @@ function updateNamedCousins(rootNode, props) {
// That's probably okay; we don't support it just as we don't support
// mixing React radio buttons with non-React ones.
var otherInstance = ReactDOMComponentTree.getInstanceFromNode(otherNode);
// TODO: Ensure that otherInstance is the current Fiber instead of wip.
invariant(
otherInstance,
'ReactDOMInput: Mixing React and non-React radio inputs with the ' +
@@ -282,7 +282,7 @@ module.exports = function<T, P, I, TI, C>(
// Commit the work prepared earlier.
const newProps = finishedWork.memoizedProps;
const oldProps = current.memoizedProps;
commitUpdate(instance, oldProps, newProps);
commitUpdate(instance, oldProps, newProps, finishedWork);
}
detachRefIfNeeded(current, finishedWork);
return;
@@ -54,7 +54,7 @@ export type HostConfig<T, P, I, TI, C> = {
createInstance(type : T, props : P, children : HostChildren<I | TI>, internalInstanceHandle : OpaqueNode) : I,
prepareUpdate(instance : I, oldProps : P, newProps : P) : boolean,
commitUpdate(instance : I, oldProps : P, newProps : P) : void,
commitUpdate(instance : I, oldProps : P, newProps : P, internalInstanceHandle : OpaqueNode) : void,
createTextInstance(text : string, internalInstanceHandle : OpaqueNode) : TI,
commitTextUpdate(textInstance : TI, oldText : string, newText : string) : void,
@@ -127,7 +127,10 @@ var EventPluginHub = {
// live here; needs to be moved to a better place soon
if (typeof inst.tag === 'number') {
// TODO: This is not safe because we might want the *other* Fiber's
// props depending on which is the current one.
// props depending on which is the current one. This will usually be the
// current Fiber but if we're walking up the tree using TreeTraversal for
// bubbling, we will not be guaranteed to walk up the current tree when
// a Fiber has been reused.
const props = inst.memoizedProps;
listener = props[registrationName];
if (shouldPreventMouseEvent(registrationName, inst.type, props)) {