un-revert textContent, support multi-line strings in modern browsers
reverts 23ab30ff873fba816129cafa0c40112dd2ee990d because the issue it fixed doesn't seem to be a problem anymore. textContent should be better for more things anyway, as the original 309a88bcf62c1c64a2b91c0eb753c19209a425b2 indicates. It should be faster because innerText requires layout. This also allows us to use strings with newlines in our rendered output and have confidence that they will render the same on subsequent re-renders. This is especially useful for es6-style backtick multi-line strings. This will be more consistent as textContent is supported almost everwhere so we won't have differing behavior between webkit and firefox. see https://github.com/facebook/react/issues/1080
Jason Bonta committed
Feb 13, 2014 at 18:11 UTC
47645854f962aef00c9c7b9d566ea21b8ab3b8b6
1 file changed
+5
-3
src/browser/dom/getTextContentAccessor.js
+5
-3
@@ -30,9 +30,11 @@ var contentKey = null;
30
*/
31
function getTextContentAccessor() {
32
if (!contentKey && ExecutionEnvironment.canUseDOM) {
33
- contentKey = 'innerText' in document.createElement('div') ?
34
- 'innerText' :
35
- 'textContent';
33
+ // Prefer textContent to innerText because many browsers support both but
34
+ // SVG <text> elements don't support innerText even when <div> does.
35
+ contentKey = 'textContent' in document.createElement('div') ?
36
+ 'textContent' :
37
+ 'innerText';
38
}
39
return contentKey;
40
}