Last active
June 11, 2016 02:35
-
-
Save eligrey/5a600bade889e54f4b7f1cce42165288 to your computer and use it in GitHub Desktop.
Workaround for Mozilla bug #1276438 in Firefox
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
// Workaround for Mozilla bug #1276438 in Firefox | |
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1276438 | |
if (!Object.getOwnPropertyDescriptor(Document.prototype, "body")) | |
Object.defineProperty(Document.prototype, "body", { | |
enumerable: true | |
, configurable: true | |
, get() { | |
return this.evaluate( | |
"/*[local-name()='html'][namespace-uri()='http://www.w3.org/1999/xhtml']" | |
+ "/*[local-name()='body'][namespace-uri()='http://www.w3.org/1999/xhtml']" | |
, this, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null | |
).singleNodeValue; | |
} | |
, set(replacement) { | |
var body = this.body; | |
body.parentElement.replaceChild(replacement, body); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment