Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The IE11 document.implementation.createHTMLDocument API requires the title argument to be specified #10865

Closed
leidegre opened this issue Sep 27, 2017 · 9 comments

Comments

@leidegre
Copy link
Contributor

leidegre commented Sep 27, 2017

Do you want to request a feature or report a bug?

bug

What is the current behavior?

React interactivity lost, React crash?

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template: https://jsfiddle.net/ebsrpraL/).

Run with react-dom.development.js in IE11, not sure exactly what the exact repo steps are the fix I've attempted for IE11 was to simply pass an empty string.

var normalizeHTML = function (parent, html) {
    if (!testDocument) {
      testDocument = document.implementation.createHTMLDocument(""); // fix for IE11 here
    }
    var testElement = parent.namespaceURI === HTML_NAMESPACE ? testDocument.createElement(parent.tagName) : testDocument.createElementNS(parent.namespaceURI, parent.tagName);
    testElement.innerHTML = html;
    return testElement.innerHTML;
  };
}

Source

var normalizeHTML = function(parent: Element, html: string) {
if (!testDocument) {
testDocument = document.implementation.createHTMLDocument();
}
var testElement = parent.namespaceURI === HTML_NAMESPACE
? testDocument.createElement(parent.tagName)
: testDocument.createElementNS(
(parent.namespaceURI: any),
parent.tagName,
);
testElement.innerHTML = html;
return testElement.innerHTML;
};
}

MDN docs here.

What is the expected behavior?

Well, that React does not crash in dev mode and that interactively continues to work.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

react@16.0.0 IE11

@leidegre leidegre changed the title The IE11 document.implementation.createHTMLDocument API requires the title argument to be set The IE11 document.implementation.createHTMLDocument API requires the title argument to be specified Sep 28, 2017
@leidegre
Copy link
Contributor Author

This only impacts IE11 users running a development build of React, it's not an issue in production. It's a nuisance but easy to work around with above-mentioned change.

What would be the appropriate fix for this? because we, unfortunately, have to support IE11. I can perform the work if I know what's expected or a reasonable fix for the issue.

@gaearon
Copy link
Collaborator

gaearon commented Sep 28, 2017

Can you provide a failing unit test? It is not very clear to me what this code is referring to.

@leidegre
Copy link
Contributor Author

leidegre commented Sep 28, 2017

...and I thought I was being super clear!

document.implementation.createHTMLDocument(""); // fix for IE11 here

Unless that empty string "" is passed react.development.js won't function properly in IE11.

Edit: this is an IE11 quirk, I don't think any unit test would fail from this because it would require the test to run inside IE11.

@gaearon
Copy link
Collaborator

gaearon commented Sep 28, 2017

Do you want to send a PR with this change?

@leidegre
Copy link
Contributor Author

Absolutely, if it's an acceptable change.

@gaearon
Copy link
Collaborator

gaearon commented Sep 28, 2017

Sounds reasonable to me. :-)

@gaearon
Copy link
Collaborator

gaearon commented Sep 29, 2017

Fixed via #10921.

@Gekkio
Copy link

Gekkio commented Oct 6, 2017

This is already fixed, but just for the record: IE10 is also affected by the original problem. An error is thrown and it's the line containing the createHTMLDocument call.

@gaearon
Copy link
Collaborator

gaearon commented Nov 3, 2017

React 16.1.0-beta has been released. Please update react, react-dom, and react-test-renderer (if you use it) to this version and let us know if it solved the issue! We’d appreciate if you could test before Monday when we plan to get 16.1.0 out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants