facebook/react — pull request #684 by syranide (2013-12-20 20:12:04+00:00)
Title: Use feature detection and more robust recovering of whitespace for innerHTML in IE8

`dangerouslySetInnerHTML` in IE8 collapses whitespace in **root TextNodes** and removes leading whitespace. Your current fix for this is to replace any first space with ` ` which is a surprisingly good and simple fix, but it does this for all browsers and doesn't solve the collapsing whitespace (or any whitespace besides space).

I propose the following fix instead, which makes it work identically to all other browsers at minimal cost, and does so via feature detection so only IE8 is affected.

*Disclaimer: if the root node is a TABLE/TBODY/OL/SELECT or anything else that (kind of) doesn't support TextNodes AND there is whitespace in the beginning of the HTML, this will create a faulty TextNode with whitespace (when it actually should be removed)... however, the code/size penalty for solving this is unreasonably large when the use-cases are virtually none, as far as I'm aware*

`
raw gz Compared to master @ 09bdcefd4f246eb49b82aa5bfece8d40cb8a2fca
= = build/JSXTransformer.js
+3155 +642 build/react-test.js
+658 +217 build/react-with-addons.js
+169 +74 build/react-with-addons.min.js
+658 +214 build/react.js
+169 +91 build/react.min.js
`