Extract event listener from memoizedProps on Fiber instances

This makes some basic events work with Fiber.

This is however not a complete solution since we may be reading the wrong
Fiber.
This commit is contained in:
Sebastian Markbage
2016-11-16 15:56:13 +00:00
parent b3af02a3cd
commit 4e2688db4a
3 changed files with 11 additions and 4 deletions
-3
View File
@@ -137,9 +137,6 @@ src/renderers/dom/shared/eventPlugins/__tests__/ChangeEventPlugin-test.js
* should listen for both change and input events when supported
* should only fire events when the value changes for range inputs
src/renderers/dom/shared/eventPlugins/__tests__/EnterLeaveEventPlugin-test.js
* should set relatedTarget properly in iframe
src/renderers/dom/shared/eventPlugins/__tests__/SelectEventPlugin-test.js
* should skip extraction if no listeners are present
* should extract if an `onSelect` listener is present
+3
View File
@@ -605,6 +605,9 @@ src/renderers/dom/shared/eventPlugins/__tests__/BeforeInputEventPlugin-test.js
src/renderers/dom/shared/eventPlugins/__tests__/ChangeEventPlugin-test.js
* should unmount
src/renderers/dom/shared/eventPlugins/__tests__/EnterLeaveEventPlugin-test.js
* should set relatedTarget properly in iframe
src/renderers/dom/shared/eventPlugins/__tests__/FallbackCompositionState-test.js
* extracts value via `getText()`
* extracts when inserted at start of text
@@ -96,7 +96,14 @@ var EventPluginHub = {
* @return {?function} The stored callback.
*/
getListener: function(inst, registrationName) {
var listener = inst._currentElement.props[registrationName];
var listener;
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.
listener = inst.memoizedProps[registrationName];
} else {
listener = inst._currentElement.props[registrationName];
}
invariant(
!listener || typeof listener === 'function',
'Expected %s listener to be a function, instead got type %s',