Skip to content

Commit

Permalink
Restore DOM selection and suppress events in updateContainer
Browse files Browse the repository at this point in the history
Not sure if we need this elsewhere too but this makes Draft mostly work.
  • Loading branch information
sophiebits committed Nov 18, 2016
1 parent dfdff2b commit 9cf5de5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 0 additions & 3 deletions scripts/fiber/tests-failing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ src/renderers/dom/shared/eventPlugins/__tests__/SimpleEventPlugin-test.js
* should not forward clicks when it starts out disabled
* should not forward clicks when it becomes disabled

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
Expand Down
1 change: 1 addition & 0 deletions scripts/fiber/tests-passing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,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
Expand Down
11 changes: 10 additions & 1 deletion src/renderers/dom/fiber/ReactDOMFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@

import type { HostChildren } from 'ReactFiberReconciler';

var ReactBrowserEventEmitter = require('ReactBrowserEventEmitter');
var ReactControlledComponent = require('ReactControlledComponent');
var ReactFiberReconciler = require('ReactFiberReconciler');
var ReactDOMComponentTree = require('ReactDOMComponentTree');
var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
var ReactDOMFiberComponent = require('ReactDOMFiberComponent');
var ReactDOMInjection = require('ReactDOMInjection');
var ReactFiberReconciler = require('ReactFiberReconciler');
var ReactInputSelection = require('ReactInputSelection');

ReactDOMInjection.inject();
ReactControlledComponent.injection.injectFiberControlledHostComponent(
Expand Down Expand Up @@ -63,8 +65,15 @@ var DOMRenderer = ReactFiberReconciler({

updateContainer(container : Container, children : HostChildren<Instance | TextInstance>) : void {
// TODO: Containers should update similarly to other parents.
var eventsEnabled = ReactBrowserEventEmitter.isEnabled();
ReactBrowserEventEmitter.setEnabled(false);
var selection = ReactInputSelection.getSelectionInformation();

container.innerHTML = '';
recursivelyAppendChildren(container, children);

ReactInputSelection.restoreSelection(selection);
ReactBrowserEventEmitter.setEnabled(eventsEnabled);
},

createInstance(
Expand Down

0 comments on commit 9cf5de5

Please sign in to comment.