@samitouri / QOS-React-2 / commits / b36e05b0af

Fix ReactEmptyComponent disappearing and throwing in IE8

Andreas Svensson committed May 8, 2014 at 17:05 UTC b36e05b0af5658a9c50dd6a26e46aa08c85ea2d9
3 files changed +15 -5
src/browser/ui/ReactDefaultInjection.js
+1 -1
@@ -97,7 +97,7 @@ function inject() {
97 ReactInjection.DOMProperty.injectDOMPropertyConfig(HTMLDOMPropertyConfig);
98 ReactInjection.DOMProperty.injectDOMPropertyConfig(SVGDOMPropertyConfig);
99
100 - ReactInjection.EmptyComponent.injectEmptyComponent(ReactDOM.script);
100 + ReactInjection.EmptyComponent.injectEmptyComponent(ReactDOM.noscript);
101
102 ReactInjection.Updates.injectReconcileTransaction(
103 ReactComponentBrowserEnvironment.ReactReconcileTransaction
src/browser/ui/dom/setInnerHTML.js
+11 -1
@@ -52,7 +52,17 @@ if (ExecutionEnvironment.canUseDOM) {
52 node.parentNode.replaceChild(node, node);
53 }
54
55 - if (html.match(/^[ \r\n\t\f]/)) {
55 + // We also implement a workaround for non-visible tags disappearing into
56 + // thin air on IE8, this only happens if there is no visible text
57 + // in-front of the non-visible tags. Piggyback on the whitespace fix
58 + // and simply check if any non-visible tags appear in the source.
59 + if (html.match(/^[ \r\n\t\f]/) ||
60 + html[0] === '<' && (
61 + html.indexOf('<noscript') !== -1 ||
62 + html.indexOf('<script') !== -1 ||
63 + html.indexOf('<style') !== -1 ||
64 + html.indexOf('<meta') !== -1 ||
65 + html.indexOf('<link') !== -1)) {
66 // Recover leading whitespace by temporarily prepending any character.
67 // \uFEFF has the potential advantage of being zero-width/invisible.
68 node.innerHTML = '\uFEFF' + html;
src/core/__tests__/ReactCompositeComponent-test.js
+3 -3
@@ -129,7 +129,7 @@ describe('ReactCompositeComponent', function() {
129 .toBeDOMComponentWithTag('a');
130 });
131
132 - it('should render null and false as a script tag under the hood', () => {
132 + it('should render null and false as a noscript tag under the hood', () => {
133 var Component1 = React.createClass({
134 render: function() {
135 return null;
@@ -145,10 +145,10 @@ describe('ReactCompositeComponent', function() {
145 var instance2 = ReactTestUtils.renderIntoDocument(<Component2 />);
146 reactComponentExpect(instance1)
147 .expectRenderedChild()
148 - .toBeDOMComponentWithTag('script');
148 + .toBeDOMComponentWithTag('noscript');
149 reactComponentExpect(instance2)
150 .expectRenderedChild()
151 - .toBeDOMComponentWithTag('script');
151 + .toBeDOMComponentWithTag('noscript');
152 });
153
154 it('should still throw when rendering to undefined', () => {