Skip to content

Instantly share code, notes, and snippets.

@eligrey
Last active June 11, 2016 02:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eligrey/5a600bade889e54f4b7f1cce42165288 to your computer and use it in GitHub Desktop.
Save eligrey/5a600bade889e54f4b7f1cce42165288 to your computer and use it in GitHub Desktop.
Workaround for Mozilla bug #1276438 in Firefox
// 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