diff --git a/scripts/fiber/tests-failing.txt b/scripts/fiber/tests-failing.txt index 23726bdeccb9a..cf51db15c69f5 100644 --- a/scripts/fiber/tests-failing.txt +++ b/scripts/fiber/tests-failing.txt @@ -85,9 +85,6 @@ src/renderers/dom/shared/eventPlugins/__tests__/SimpleEventPlugin-test.js * should not forward clicks when it becomes disabled * should work correctly if the listener is changed -src/renderers/dom/shared/wrappers/__tests__/ReactDOMInput-test.js -* should control a value in reentrant events - src/renderers/dom/stack/client/__tests__/ReactDOM-test.js * throws in render() if the mount callback is not a function * throws in render() if the update callback is not a function diff --git a/scripts/fiber/tests-passing.txt b/scripts/fiber/tests-passing.txt index 9a54b3c411b83..73a95078560f9 100644 --- a/scripts/fiber/tests-passing.txt +++ b/scripts/fiber/tests-passing.txt @@ -779,6 +779,7 @@ src/renderers/dom/shared/wrappers/__tests__/ReactDOMIframe-test.js src/renderers/dom/shared/wrappers/__tests__/ReactDOMInput-test.js * should properly control a value even if no event listener exists +* should control a value in reentrant events * should control values in reentrant events with different targets * should display `defaultValue` of number 0 * only assigns defaultValue if it changes diff --git a/src/renderers/dom/fiber/ReactDOMFiber.js b/src/renderers/dom/fiber/ReactDOMFiber.js index 4cc6c2ac913e1..a18e57317a537 100644 --- a/src/renderers/dom/fiber/ReactDOMFiber.js +++ b/src/renderers/dom/fiber/ReactDOMFiber.js @@ -16,12 +16,14 @@ import type { Fiber } from 'ReactFiber'; import type { HostChildren } from 'ReactFiberReconciler'; import type { ReactNodeList } from 'ReactTypes'; +var ReactBrowserEventEmitter = require('ReactBrowserEventEmitter'); var ReactControlledComponent = require('ReactControlledComponent'); var ReactDOMComponentTree = require('ReactDOMComponentTree'); var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags'); var ReactDOMFiberComponent = require('ReactDOMFiberComponent'); var ReactDOMInjection = require('ReactDOMInjection'); var ReactFiberReconciler = require('ReactFiberReconciler'); +var ReactInputSelection = require('ReactInputSelection'); var ReactInstanceMap = require('ReactInstanceMap'); var ReactPortal = require('ReactPortal'); @@ -29,11 +31,6 @@ var findDOMNode = require('findDOMNode'); var invariant = require('invariant'); var warning = require('warning'); -ReactDOMInjection.inject(); -ReactControlledComponent.injection.injectFiberControlledHostComponent( - ReactDOMFiberComponent -); - var { createElement, setInitialProperties, @@ -55,6 +52,7 @@ type Container = Element; type Props = { className ?: string }; type Instance = Element; type TextInstance = Text; +type EnvironmentState = {| eventsEnabled : boolean, selectionInformation : mixed |}; function recursivelyAppendChildren(parent : Element, child : HostChildren) { if (!child) { @@ -75,6 +73,20 @@ function recursivelyAppendChildren(parent : Element, child : HostChildren) : void { // TODO: Containers should update similarly to other parents. container.innerHTML = ''; diff --git a/src/renderers/noop/ReactNoop.js b/src/renderers/noop/ReactNoop.js index ebac23f6a24f9..16bcd0142ead7 100644 --- a/src/renderers/noop/ReactNoop.js +++ b/src/renderers/noop/ReactNoop.js @@ -156,6 +156,12 @@ var NoopRenderer = ReactFiberReconciler({ scheduledDeferredCallback = callback; }, + prepareForCommit() : void { + }, + + resetAfterCommit(state : void) : void { + }, + }); var rootContainers = new Map(); diff --git a/src/renderers/shared/fiber/ReactFiberBeginWork.js b/src/renderers/shared/fiber/ReactFiberBeginWork.js index 1a492a46dd14d..33822d201fc36 100644 --- a/src/renderers/shared/fiber/ReactFiberBeginWork.js +++ b/src/renderers/shared/fiber/ReactFiberBeginWork.js @@ -57,8 +57,8 @@ var { var ReactCurrentOwner = require('ReactCurrentOwner'); var ReactFiberClassComponent = require('ReactFiberClassComponent'); -module.exports = function( - config : HostConfig, +module.exports = function( + config : HostConfig, scheduleUpdate : (fiber: Fiber) => void ) { diff --git a/src/renderers/shared/fiber/ReactFiberCommitWork.js b/src/renderers/shared/fiber/ReactFiberCommitWork.js index 6886f5ce2e9b8..291a91c046fe2 100644 --- a/src/renderers/shared/fiber/ReactFiberCommitWork.js +++ b/src/renderers/shared/fiber/ReactFiberCommitWork.js @@ -32,8 +32,8 @@ var { Callback, } = require('ReactTypeOfSideEffect'); -module.exports = function( - config : HostConfig, +module.exports = function( + config : HostConfig, trapError : (failedFiber : Fiber, error: Error, isUnmounting : boolean) => void ) { diff --git a/src/renderers/shared/fiber/ReactFiberCompleteWork.js b/src/renderers/shared/fiber/ReactFiberCompleteWork.js index dc4ab68443318..b9884bbc9a3a9 100644 --- a/src/renderers/shared/fiber/ReactFiberCompleteWork.js +++ b/src/renderers/shared/fiber/ReactFiberCompleteWork.js @@ -43,7 +43,7 @@ var { Callback, } = ReactTypeOfSideEffect; -module.exports = function(config : HostConfig) { +module.exports = function(config : HostConfig) { const createInstance = config.createInstance; const createTextInstance = config.createTextInstance; diff --git a/src/renderers/shared/fiber/ReactFiberReconciler.js b/src/renderers/shared/fiber/ReactFiberReconciler.js index b1344c412137e..e23749c40b0eb 100644 --- a/src/renderers/shared/fiber/ReactFiberReconciler.js +++ b/src/renderers/shared/fiber/ReactFiberReconciler.js @@ -44,7 +44,7 @@ export type HostChildren = null | void | I | HostChildNode; type OpaqueNode = Fiber; -export type HostConfig = { +export type HostConfig = { // TODO: We don't currently have a quick way to detect that children didn't // reorder so we host will always need to check the set. We should make a flag @@ -66,6 +66,9 @@ export type HostConfig = { scheduleAnimationCallback(callback : () => void) : void, scheduleDeferredCallback(callback : (deadline : Deadline) => void) : void, + prepareForCommit() : ES, + resetAfterCommit(state : ES) : void, + useSyncScheduling ?: boolean, }; @@ -91,7 +94,7 @@ getContextForSubtree._injectFiber(function(fiber : Fiber) { return processChildContext(fiber, findCurrentUnmaskedContext(fiber)); }); -module.exports = function(config : HostConfig) : Reconciler { +module.exports = function(config : HostConfig) : Reconciler { var { scheduleWork, diff --git a/src/renderers/shared/fiber/ReactFiberScheduler.js b/src/renderers/shared/fiber/ReactFiberScheduler.js index 71aff51a26bec..48ebd3ee80e6f 100644 --- a/src/renderers/shared/fiber/ReactFiberScheduler.js +++ b/src/renderers/shared/fiber/ReactFiberScheduler.js @@ -64,7 +64,7 @@ type TrappedError = { error: any, }; -module.exports = function(config : HostConfig) { +module.exports = function(config : HostConfig) { const { beginWork } = ReactFiberBeginWork(config, scheduleUpdate); const { completeWork } = ReactFiberCompleteWork(config); const { commitInsertion, commitDeletion, commitWork, commitLifeCycles } = @@ -161,6 +161,8 @@ module.exports = function(config : HostConfig) { } function commitAllWork(finishedWork : Fiber) { + const environmentState = config.prepareForCommit(); + // Commit all the side-effects within a tree. // First, we'll perform all the host insertions, updates, deletions and // ref unmounts. @@ -238,6 +240,8 @@ module.exports = function(config : HostConfig) { // The task work includes batched updates and error handling. performTaskWork(); + + config.resetAfterCommit(environmentState); } function resetWorkPriority(workInProgress : Fiber) {