Fix ReactEmptyComponent disappearing and throwing in IE8

This commit is contained in:
Andreas Svensson
2014-06-20 10:08:49 +02:00
parent 3c64461383
commit b36e05b0af
3 changed files with 15 additions and 5 deletions
+1 -1
View File
@@ -97,7 +97,7 @@ function inject() {
ReactInjection.DOMProperty.injectDOMPropertyConfig(HTMLDOMPropertyConfig);
ReactInjection.DOMProperty.injectDOMPropertyConfig(SVGDOMPropertyConfig);
ReactInjection.EmptyComponent.injectEmptyComponent(ReactDOM.script);
ReactInjection.EmptyComponent.injectEmptyComponent(ReactDOM.noscript);
ReactInjection.Updates.injectReconcileTransaction(
ReactComponentBrowserEnvironment.ReactReconcileTransaction
+11 -1
View File
@@ -52,7 +52,17 @@ if (ExecutionEnvironment.canUseDOM) {
node.parentNode.replaceChild(node, node);
}
if (html.match(/^[ \r\n\t\f]/)) {
// We also implement a workaround for non-visible tags disappearing into
// thin air on IE8, this only happens if there is no visible text
// in-front of the non-visible tags. Piggyback on the whitespace fix
// and simply check if any non-visible tags appear in the source.
if (html.match(/^[ \r\n\t\f]/) ||
html[0] === '<' && (
html.indexOf('<noscript') !== -1 ||
html.indexOf('<script') !== -1 ||
html.indexOf('<style') !== -1 ||
html.indexOf('<meta') !== -1 ||
html.indexOf('<link') !== -1)) {
// Recover leading whitespace by temporarily prepending any character.
// \uFEFF has the potential advantage of being zero-width/invisible.
node.innerHTML = '\uFEFF' + html;
@@ -129,7 +129,7 @@ describe('ReactCompositeComponent', function() {
.toBeDOMComponentWithTag('a');
});
it('should render null and false as a script tag under the hood', () => {
it('should render null and false as a noscript tag under the hood', () => {
var Component1 = React.createClass({
render: function() {
return null;
@@ -145,10 +145,10 @@ describe('ReactCompositeComponent', function() {
var instance2 = ReactTestUtils.renderIntoDocument(<Component2 />);
reactComponentExpect(instance1)
.expectRenderedChild()
.toBeDOMComponentWithTag('script');
.toBeDOMComponentWithTag('noscript');
reactComponentExpect(instance2)
.expectRenderedChild()
.toBeDOMComponentWithTag('script');
.toBeDOMComponentWithTag('noscript');
});
it('should still throw when rendering to undefined', () => {