mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Merge pull request #1495 from syranide/ie8noscript
Fix ReactEmptyComponent disappearing and throwing in IE8
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user