Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
81159 views
1
/**
2
* Copyright 2013-2014, Facebook, Inc.
3
* All rights reserved.
4
*
5
* This source code is licensed under the BSD-style license found in the
6
* LICENSE file in the root directory of this source tree. An additional grant
7
* of patent rights can be found in the PATENTS file in the same directory.
8
*
9
* @providesModule getTextContentAccessor
10
*/
11
12
"use strict";
13
14
var ExecutionEnvironment = require('ExecutionEnvironment');
15
16
var contentKey = null;
17
18
/**
19
* Gets the key used to access text content on a DOM node.
20
*
21
* @return {?string} Key used to access text content.
22
* @internal
23
*/
24
function getTextContentAccessor() {
25
if (!contentKey && ExecutionEnvironment.canUseDOM) {
26
// Prefer textContent to innerText because many browsers support both but
27
// SVG <text> elements don't support innerText even when <div> does.
28
contentKey = 'textContent' in document.documentElement ?
29
'textContent' :
30
'innerText';
31
}
32
return contentKey;
33
}
34
35
module.exports = getTextContentAccessor;
36
37