UNPKG

browsernizr

Version:

Modernizr wrapper for use with browserify

27 lines (22 loc) 755 B
var createElement = require('./createElement.js'); var isSVG = require('./isSVG.js'); /** * getBody returns the body of a document, or an element that can stand in for * the body if a real body does not exist * * @access private * @function getBody * @returns {HTMLElement|SVGElement} Returns the real body of a document, or an * artificially created element that stands in for the body */ function getBody() { // After page load injecting a fake body doesn't work so check if body exists var body = document.body; if (!body) { // Can't use the real body create a fake one. body = createElement(isSVG ? 'svg' : 'body'); body.fake = true; } return body; } module.exports = getBody;