15
15
var Danger = require ( 'Danger' ) ;
16
16
var ReactMultiChildUpdateTypes = require ( 'ReactMultiChildUpdateTypes' ) ;
17
17
18
- var getTextContentAccessor = require ( 'getTextContentAccessor ' ) ;
18
+ var setTextContent = require ( 'setTextContent ' ) ;
19
19
var invariant = require ( 'invariant' ) ;
20
20
21
- /**
22
- * The DOM property to use when setting text content.
23
- *
24
- * @type {string }
25
- * @private
26
- */
27
- var textContentAccessor = getTextContentAccessor ( ) ;
28
-
29
21
/**
30
22
* Inserts `childNode` as a child of `parentNode` at the `index`.
31
23
*
@@ -45,45 +37,14 @@ function insertChildAt(parentNode, childNode, index) {
45
37
) ;
46
38
}
47
39
48
- var updateTextContent ;
49
- if ( textContentAccessor === 'textContent' ) {
50
- /**
51
- * Sets the text content of `node` to `text`.
52
- *
53
- * @param {DOMElement } node Node to change
54
- * @param {string } text New text content
55
- */
56
- updateTextContent = function ( node , text ) {
57
- node . textContent = text ;
58
- } ;
59
- } else {
60
- /**
61
- * Sets the text content of `node` to `text`.
62
- *
63
- * @param {DOMElement } node Node to change
64
- * @param {string } text New text content
65
- */
66
- updateTextContent = function ( node , text ) {
67
- // In order to preserve newlines correctly, we can't use .innerText to set
68
- // the contents (see #1080), so we empty the element then append a text node
69
- while ( node . firstChild ) {
70
- node . removeChild ( node . firstChild ) ;
71
- }
72
- if ( text ) {
73
- var doc = node . ownerDocument || document ;
74
- node . appendChild ( doc . createTextNode ( text ) ) ;
75
- }
76
- } ;
77
- }
78
-
79
40
/**
80
41
* Operations for updating with DOM children.
81
42
*/
82
43
var DOMChildrenOperations = {
83
44
84
45
dangerouslyReplaceNodeWithMarkup : Danger . dangerouslyReplaceNodeWithMarkup ,
85
46
86
- updateTextContent : updateTextContent ,
47
+ updateTextContent : setTextContent ,
87
48
88
49
/**
89
50
* Updates a component's children by processing a series of updates. The
@@ -156,7 +117,7 @@ var DOMChildrenOperations = {
156
117
) ;
157
118
break ;
158
119
case ReactMultiChildUpdateTypes . TEXT_CONTENT :
159
- updateTextContent (
120
+ setTextContent (
160
121
update . parentNode ,
161
122
update . textContent
162
123
) ;
0 commit comments