Created
November 19, 2015 06:43
-
-
Save esprehn/fb0d1c1e8942762497e7 to your computer and use it in GitHub Desktop.
Create registration context
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var createNewRegistrationContext = (function() { | |
// This is slow and means using more memory keeping the iframe window alive, | |
// but there's no other way to get a fresh registration context. :( | |
var iframe = document.createElement("iframe"); | |
iframe.style.display = "none"; | |
document.documentElement.appendChild(iframe); | |
var lastDocument = iframe.contentDocument; | |
return function() { | |
// This keeps nesting template documents to create new registration | |
// contexts. | |
lastDocument = lastDocument.createElement("template").content. | |
ownerDocument.implementation.createHTMLDocument(null); | |
return lastDocument; | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment