Skip to content

Commit

Permalink
Changed body to getBody and made it a method, #877.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanseddon committed Apr 7, 2013
1 parent de7fba8 commit 804037a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
3 changes: 2 additions & 1 deletion feature-detects/forms/inputnumber-l10n.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define(['Modernizr', 'createElement', 'docElement', 'body'], function( Modernizr, createElement, docElement ) {
define(['Modernizr', 'createElement', 'docElement', 'getBody'], function( Modernizr, createElement, docElement, getBody ) {
// input[type="number"] localized input/output
// // Detects whether input type="number" is capable of receiving and
// // displaying localized numbers, e.g. with comma separator
Expand All @@ -9,6 +9,7 @@ define(['Modernizr', 'createElement', 'docElement', 'body'], function( Modernizr
Modernizr.addTest('localizednumber', function() {
var el = createElement('div');
var diff;
var body = getBody();

var root = (function() {
return docElement.insertBefore(body, docElement.firstElementChild || docElement.firstChild);
Expand Down
12 changes: 0 additions & 12 deletions src/body.js

This file was deleted.

16 changes: 16 additions & 0 deletions src/getBody.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
define(['createElement'], function( createElement ) {
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('body');
body.fake = true;
}

return body;
}

return getBody;
});
3 changes: 2 additions & 1 deletion src/injectElementWithStyles.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define(['ModernizrProto', 'docElement', 'createElement', 'body'], function( ModernizrProto, docElement, createElement, body ) {
define(['ModernizrProto', 'docElement', 'createElement', 'getBody'], function( ModernizrProto, docElement, createElement, getBody ) {
// Inject element with style element and some CSS rules
function injectElementWithStyles( rule, callback, nodes, testnames ) {
var mod = 'modernizr';
Expand All @@ -7,6 +7,7 @@ define(['ModernizrProto', 'docElement', 'createElement', 'body'], function( Mode
var node;
var docOverflow;
var div = createElement('div');
var body = getBody();

if ( parseInt(nodes, 10) ) {
// In order not to give false positives we create a node for each test
Expand Down

0 comments on commit 804037a

Please sign in to comment.