-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added body module, altered tests that need it #877
* body module will check for body or create a fakeBody * Changed tests to either use testStyles or inject body module
- Loading branch information
1 parent
5a1a396
commit de7fba8
Showing
5 changed files
with
56 additions
and
69 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
define(['Modernizr', 'createElement', 'docElement'], function( Modernizr, createElement, docElement ) { | ||
define(['Modernizr', 'createElement', 'docElement', 'testStyles'], function( Modernizr, createElement, docElement, testStyles ) { | ||
// By @mathias, based on http://mths.be/axh | ||
Modernizr.addTest('details', function() { | ||
var el = createElement('details'); | ||
var fake; | ||
var diff; | ||
|
||
if (!('open' in el)) { // return early if possible; thanks @aFarkas! | ||
return false; | ||
} | ||
var root = document.body || (function() { | ||
fake = true; | ||
return docElement.insertBefore(createElement('body'), docElement.firstElementChild || docElement.firstChild); | ||
}()); | ||
el.innerHTML = '<summary>a</summary>b'; | ||
el.style.display = 'block'; | ||
root.appendChild(el); | ||
var diff = el.offsetHeight; | ||
el.open = true; | ||
diff = diff != el.offsetHeight; | ||
root.removeChild(el); | ||
fake && root.parentNode.removeChild(root); | ||
|
||
testStyles('#modernizr details{display:block}', function( node ) { | ||
node.appendChild(el); | ||
el.innerHTML = '<summary>a</summary>b'; | ||
diff = el.offsetHeight; | ||
el.open = true; | ||
diff = diff != el.offsetHeight; | ||
}); | ||
|
||
|
||
return diff; | ||
}); | ||
}); |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
define(['createElement'], function( createElement ) { | ||
// After page load injecting a fake body doesn't work so check if body exists | ||
var body = document.body; | ||
// Can we use the real body or should we create a fake one. | ||
var fakeBody = body || createElement('body'); | ||
|
||
if(!body) { | ||
fakeBody.fake = true; | ||
} | ||
|
||
return fakeBody; | ||
}); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ryanseddon
Author
Member
|
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
I think this commit may have contributed to the error logged in #1836, worth a look.