1515var Danger = require ( 'Danger' ) ;
1616var ReactMultiChildUpdateTypes = require ( 'ReactMultiChildUpdateTypes' ) ;
1717
18- var getTextContentAccessor = require ( 'getTextContentAccessor ' ) ;
18+ var setTextContent = require ( 'setTextContent ' ) ;
1919var invariant = require ( 'invariant' ) ;
2020
21- /**
22- * The DOM property to use when setting text content.
23- *
24- * @type {string }
25- * @private
26- */
27- var textContentAccessor = getTextContentAccessor ( ) ;
28-
2921/**
3022 * Inserts `childNode` as a child of `parentNode` at the `index`.
3123 *
@@ -45,45 +37,14 @@ function insertChildAt(parentNode, childNode, index) {
4537 ) ;
4638}
4739
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-
7940/**
8041 * Operations for updating with DOM children.
8142 */
8243var DOMChildrenOperations = {
8344
8445 dangerouslyReplaceNodeWithMarkup : Danger . dangerouslyReplaceNodeWithMarkup ,
8546
86- updateTextContent : updateTextContent ,
47+ updateTextContent : setTextContent ,
8748
8849 /**
8950 * Updates a component's children by processing a series of updates. The
@@ -156,7 +117,7 @@ var DOMChildrenOperations = {
156117 ) ;
157118 break ;
158119 case ReactMultiChildUpdateTypes . TEXT_CONTENT :
159- updateTextContent (
120+ setTextContent (
160121 update . parentNode ,
161122 update . textContent
162123 ) ;
0 commit comments