Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove ReactInputSelection plugin
  • Loading branch information
acusti committed Oct 24, 2017
commit 0d4dddc44b8e4fce3c43303c8434e0279fcee359
5 changes: 0 additions & 5 deletions packages/react-dom/src/client/ReactDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ var ReactDOMFiberComponent = require('ReactDOMFiberComponent');
var ReactDOMFrameScheduling = require('ReactDOMFrameScheduling');
var ReactGenericBatching = require('ReactGenericBatching');
var ReactFiberReconciler = require('react-reconciler');
var ReactInputSelection = require('ReactInputSelection');
var ReactInstanceMap = require('ReactInstanceMap');
var ReactPortal = require('ReactPortal');
var ReactVersion = require('ReactVersion');
Expand Down Expand Up @@ -113,7 +112,6 @@ type HostContextProd = string;
type HostContext = HostContextDev | HostContextProd;

let eventsEnabled: ?boolean = null;
let selectionInformation: ?mixed = null;

/**
* True if the supplied DOM node is a valid node element.
Expand Down Expand Up @@ -216,13 +214,10 @@ var DOMRenderer = ReactFiberReconciler({

prepareForCommit(): void {
eventsEnabled = ReactBrowserEventEmitter.isEnabled();
selectionInformation = ReactInputSelection.getSelectionInformation();
ReactBrowserEventEmitter.setEnabled(false);
},

resetAfterCommit(): void {
ReactInputSelection.restoreSelection(selectionInformation);
selectionInformation = null;
ReactBrowserEventEmitter.setEnabled(eventsEnabled);
eventsEnabled = null;
},
Expand Down
132 changes: 0 additions & 132 deletions packages/react-dom/src/client/ReactInputSelection.js

This file was deleted.

19 changes: 17 additions & 2 deletions packages/react-dom/src/events/SelectEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ var EventPropagators = require('EventPropagators');
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
var ReactBrowserEventEmitter = require('ReactBrowserEventEmitter');
var ReactDOMComponentTree = require('ReactDOMComponentTree');
var ReactInputSelection = require('ReactInputSelection');
var SyntheticEvent = require('SyntheticEvent');
var {DOCUMENT_NODE} = require('HTMLNodeType');

Expand Down Expand Up @@ -55,6 +54,22 @@ var mouseDown = false;
var isListeningToAllDependencies =
ReactBrowserEventEmitter.isListeningToAllDependencies;

/**
* Determine if a node can have a selection associated with it.
*
* @param {DOMElement} node
* @return {boolean} True if the node can have a selection.
*/
function hasSelectionCapabilities(node) {
var nodeName = node && node.nodeName && node.nodeName.toLowerCase();
return (
nodeName &&
((nodeName === 'input' && node.type === 'text') ||
nodeName === 'textarea' ||
node.contentEditable === 'true')
);
}

/**
* Get an object which is a unique representation of the current selection.
*
Expand All @@ -67,7 +82,7 @@ var isListeningToAllDependencies =
function getSelection(node) {
if (
'selectionStart' in node &&
ReactInputSelection.hasSelectionCapabilities(node)
hasSelectionCapabilities(node)
) {
return {
start: node.selectionStart,
Expand Down