-
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.
fixing scott's table display detect so it sucks less. :)
- Loading branch information
Showing
1 changed file
with
28 additions
and
22 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,25 +1,31 @@ | ||
// display: table and table-cell test. (both are tested under one name "table-cell" ) | ||
// By @scottjehl | ||
|
||
// all additional table display values are here: http://pastebin.com/Gk9PeVaQ though Scott has seen some IE false positives with that sort of weak detection. | ||
// more testing neccessary perhaps. | ||
|
||
Modernizr.addTest( "display-table",function(){ | ||
var doc = window.document, | ||
docElem = doc.documentElement, | ||
create = function( el ){ | ||
return doc.createElement( el ); | ||
}, | ||
parent = create( "div" ), | ||
child = create( "div" ), | ||
childb = create( "div" ), | ||
ret; | ||
|
||
parent.style.display = "table"; | ||
child.style.display = childb.style.display = "table-cell"; | ||
child.style.padding = childb.style.padding = "10px"; | ||
|
||
parent.appendChild( child ); | ||
parent.appendChild( childb ); | ||
docElem.insertBefore( parent, docElem.firstChild ); | ||
|
||
ret = child.offsetLeft < childb.offsetLeft; | ||
docElem.removeChild(parent); | ||
return ret; | ||
}); | ||
|
||
var doc = window.document, | ||
docElem = doc.documentElement, | ||
create = function( el ){ | ||
return doc.createElement( el ); | ||
}, | ||
parent = create( "div" ), | ||
child = create( "div" ), | ||
childb = create( "div" ), | ||
ret; | ||
|
||
parent.style.display = "table"; | ||
child.style.display = childb.style.display = "table-cell"; | ||
child.style.padding = childb.style.padding = "10px"; | ||
|
||
parent.appendChild( child ); | ||
parent.appendChild( childb ); | ||
docElem.insertBefore( parent, docElem.firstChild ); | ||
|
||
ret = child.offsetLeft < childb.offsetLeft; | ||
docElem.removeChild(parent); | ||
return ret; | ||
}); | ||
|
f4531a4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Certain circles may disagree. Frankly, whatever works, sir. :)
f4531a4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took me a while. Guessing tabs v. spaces?
May I suggest that we don't shortcut document.createElement, etc. - After gzip this ends up being bigger...
f4531a4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, good point! Sorry bout that.