@samitouri / QOS-React-2 / commits / f7a538c913

Remove getTextContentAccessor (#13434)

According to caniuse the only browsers that don't support textContent are <=IE8, which we no longer support.

Brandon Dail committed Aug 20, 2018 at 04:28 UTC f7a538c913d20d8292d7a17127ecca9910a2d351
3 files changed +2 -33
packages/react-dom/src/client/ReactDOMSelection.js
+1 -2
@@ -6,7 +6,6 @@
6 */
7
8 import getNodeForCharacterOffset from './getNodeForCharacterOffset';
9 -import getTextContentAccessor from './getTextContentAccessor';
9 import {TEXT_NODE} from '../shared/HTMLNodeType';
10
11 /**
@@ -155,7 +154,7 @@ export function setOffsets(node, offsets) {
154 const doc = node.ownerDocument || document;
155 const win = doc ? doc.defaultView : window;
156 const selection = win.getSelection();
158 - const length = node[getTextContentAccessor()].length;
157 + const length = node.textContent.length;
158 let start = Math.min(offsets.start, length);
159 let end = offsets.end === undefined ? start : Math.min(offsets.end, length);
160
packages/react-dom/src/client/getTextContentAccessor.js deleted
-28
@@ -1,28 +0,0 @@
1 -/**
2 - * Copyright (c) 2013-present, Facebook, Inc.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - */
7 -
8 -import {canUseDOM} from 'shared/ExecutionEnvironment';
9 -
10 -let contentKey = null;
11 -
12 -/**
13 - * Gets the key used to access text content on a DOM node.
14 - *
15 - * @return {?string} Key used to access text content.
16 - * @internal
17 - */
18 -function getTextContentAccessor() {
19 - if (!contentKey && canUseDOM) {
20 - // Prefer textContent to innerText because many browsers support both but
21 - // SVG <text> elements don't support innerText even when <div> does.
22 - contentKey =
23 - 'textContent' in document.documentElement ? 'textContent' : 'innerText';
24 - }
25 - return contentKey;
26 -}
27 -
28 -export default getTextContentAccessor;
packages/react-dom/src/events/FallbackCompositionState.js
+1 -3
@@ -5,8 +5,6 @@
5 * LICENSE file in the root directory of this source tree.
6 */
7
8 -import getTextContentAccessor from '../client/getTextContentAccessor';
9 -
8 /**
9 * These variables store information about text content of a target node,
10 * allowing comparison of content before and after a given event.
@@ -69,5 +67,5 @@ export function getText() {
67 if ('value' in root) {
68 return root.value;
69 }
72 - return root[getTextContentAccessor()];
70 + return root.textContent;
71 }