draft-js has this code in it (paraphrased):
function getSafeBodyFromHTML(html) {
doc = document.implementation.createHTMLDocument('foo');
doc.documentElement.innerHTML = html;
return doc.getElementsByTagName('body')[0];
}
In Chrome 56 and Firefox 45, getSafeBodyFromHTML('') returns an HTMLBodyElement. In jsdom 9.12.0, it returns undefined. getSafeBodyFromHTML('foo') does return an HTMLBodyElement like it's supposed to.
You can reproduce this in node with this code:
> var jsdom = require('jsdom').jsdom;
> var document = jsdom();
> function getSafeBodyFromHTML(html) {
... doc = document.implementation.createHTMLDocument('foo');
... doc.documentElement.innerHTML = html;
... return doc.getElementsByTagName('body')[0];
... }
> getSafeBodyFromHTML('')
undefined
> getSafeBodyFromHTML('asdf')
HTMLBodyElement {}
draft-js has this code in it (paraphrased):
In Chrome 56 and Firefox 45,
getSafeBodyFromHTML('')returns an HTMLBodyElement. In jsdom 9.12.0, it returns undefined.getSafeBodyFromHTML('foo')does return an HTMLBodyElement like it's supposed to.You can reproduce this in node with this code: