UNPKG

833 BJavaScriptView Raw
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
9'use strict';
10
11var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
12
13var contentKey = null;
14
15/**
16 * Gets the key used to access text content on a DOM node.
17 *
18 * @return {?string} Key used to access text content.
19 * @internal
20 */
21function getTextContentAccessor() {
22 if (!contentKey && ExecutionEnvironment.canUseDOM) {
23 // Prefer textContent to innerText because many browsers support both but
24 // SVG <text> elements don't support innerText even when <div> does.
25 contentKey = 'textContent' in document.documentElement ? 'textContent' : 'innerText';
26 }
27 return contentKey;
28}
29
30module.exports = getTextContentAccessor;
\No newline at end of file