fix(polyfills): implement createHTMLDocument for jquery

This commit is contained in:
Leonard Kim 2018-03-05 16:47:13 -08:00 committed by Lyubo Marinov
parent 8dc866fab3
commit 466561f99f
1 changed files with 32 additions and 0 deletions

View File

@ -149,6 +149,38 @@ function _visitNode(node, callback) {
document.cookie = '';
}
// document.implementation
//
// Required by:
// - jQuery
if (typeof document.implementation === 'undefined') {
document.implementation = {};
}
// document.implementation.createHTMLDocument
//
// Required by:
// - jQuery
if (typeof document.implementation.createHTMLDocument === 'undefined') {
document.implementation.createHTMLDocument = function(title = '') {
const htmlDocument
= new DOMParser().parseFromString(
`<html>
<head><title>${title}</title></head>
<body></body>
</html>`,
'text/xml');
Object.defineProperty(htmlDocument, 'body', {
get() {
return htmlDocument.getElementsByTagName('body')[0];
}
});
return htmlDocument;
};
}
// Element.querySelector
//
// Required by: