-
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.
- Affects fontface, touch, csstransforms3d and generatedcontent tests - Changed csstransforms3d to only inject an element an media query if needed and only have webkit and non prefixed values, see line 646. - Touch test only injects and element if first statement fails, see line 439.
- Loading branch information
1 parent
4c5d38a
commit 4807a83
Showing
1 changed file
with
32 additions
and
53 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 |
---|---|---|
|
@@ -377,54 +377,6 @@ window.Modernizr = (function( window, document, undefined ) { | |
} | ||
/*>>testallprops*/ | ||
|
||
/*>>testBundle*/ | ||
/** | ||
* testBundle tests a list of CSS features that require element and style injection. | ||
* By bundling them together we can reduce the need to touch the DOM multiple times. | ||
*/ | ||
var testBundle = (function( styles, tests ) { | ||
var style = styles.join(''), | ||
len = tests.length; | ||
|
||
injectElementWithStyles(style, function( node, rule ) { | ||
var style = document.styleSheets[document.styleSheets.length - 1], | ||
// IE8 will bork if you create a custom build that excludes both fontface and generatedcontent tests. | ||
// So we check for cssRules and that there is a rule available | ||
// More here: github.com/Modernizr/Modernizr/issues/288 & github.com/Modernizr/Modernizr/issues/293 | ||
cssText = style ? (style.cssRules && style.cssRules[0] ? style.cssRules[0].cssText : style.cssText || '') : '', | ||
children = node.childNodes, hash = {}; | ||
|
||
while ( len-- ) { | ||
hash[children[len].id] = children[len]; | ||
} | ||
|
||
/*>>touch*/ Modernizr['touch'] = ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch || (hash['touch'] && hash['touch'].offsetTop) === 9; /*>>touch*/ | ||
/*>>csstransforms3d*/ Modernizr['csstransforms3d'] = (hash['csstransforms3d'] && hash['csstransforms3d'].offsetLeft) === 9 && hash['csstransforms3d'].offsetHeight === 3; /*>>csstransforms3d*/ | ||
/*>>generatedcontent*/Modernizr['generatedcontent'] = (hash['generatedcontent'] && hash['generatedcontent'].offsetHeight) >= 1; /*>>generatedcontent*/ | ||
/*>>fontface*/ Modernizr['fontface'] = /src/i.test(cssText) && | ||
cssText.indexOf(rule.split(' ')[0]) === 0; /*>>fontface*/ | ||
}, len, tests); | ||
|
||
})([ | ||
// Pass in styles to be injected into document | ||
/*>>fontface*/ '@font-face {font-family:"font";src:url("https://")}' /*>>fontface*/ | ||
|
||
/*>>touch*/ ,['@media (',prefixes.join('touch-enabled),('),mod,')', | ||
'{#touch{top:9px;position:absolute}}'].join('') /*>>touch*/ | ||
|
||
/*>>csstransforms3d*/ ,['@media (',prefixes.join('transform-3d),('),mod,')', | ||
'{#csstransforms3d{left:9px;position:absolute;height:3px;}}'].join('')/*>>csstransforms3d*/ | ||
|
||
/*>>generatedcontent*/,['#generatedcontent:after{content:"',smile,'";visibility:hidden}'].join('') /*>>generatedcontent*/ | ||
], | ||
[ | ||
/*>>fontface*/ 'fontface' /*>>fontface*/ | ||
/*>>touch*/ ,'touch' /*>>touch*/ | ||
/*>>csstransforms3d*/ ,'csstransforms3d' /*>>csstransforms3d*/ | ||
/*>>generatedcontent*/,'generatedcontent' /*>>generatedcontent*/ | ||
|
||
]);/*>>testBundle*/ | ||
|
||
|
||
/** | ||
* Tests | ||
|
@@ -482,7 +434,17 @@ window.Modernizr = (function( window, document, undefined ) { | |
*/ | ||
|
||
tests['touch'] = function() { | ||
return Modernizr['touch']; | ||
var bool; | ||
|
||
if(('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) { | ||
bool = true; | ||
} else { | ||
injectElementWithStyles(['@media (',prefixes.join('touch-enabled),('),mod,')','{#modernizr{top:9px;position:absolute}}'].join(''), function( node ) { | ||
bool = node.offsetTop === 9; | ||
}); | ||
} | ||
|
||
return bool; | ||
}; | ||
|
||
|
||
|
@@ -684,8 +646,10 @@ window.Modernizr = (function( window, document, undefined ) { | |
if ( ret && 'webkitPerspective' in docElement.style ) { | ||
|
||
// Webkit allows this media query to succeed only if the feature is enabled. | ||
// `@media (transform-3d),(-o-transform-3d),(-moz-transform-3d),(-ms-transform-3d),(-webkit-transform-3d),(modernizr){ ... }` | ||
ret = Modernizr['csstransforms3d']; | ||
// `@media (transform-3d),(-webkit-transform-3d){ ... }` | ||
injectElementWithStyles('@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}', function( node, rule ) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
keeyipchan
|
||
ret = node.offsetLeft === 9 && node.offsetHeight === 3; | ||
}); | ||
} | ||
return ret; | ||
}; | ||
|
@@ -704,13 +668,28 @@ window.Modernizr = (function( window, document, undefined ) { | |
// WebOS github.com/Modernizr/Modernizr/issues/342 | ||
// WP7 github.com/Modernizr/Modernizr/issues/538 | ||
tests['fontface'] = function() { | ||
return Modernizr['fontface']; | ||
var bool; | ||
|
||
injectElementWithStyles('@font-face {font-family:"font";src:url("https://")}', function( node, rule ) { | ||
var style = document.styleSheets[document.styleSheets.length - 1], | ||
cssText = style ? (style.cssRules && style.cssRules[0] ? style.cssRules[0].cssText : style.cssText || '') : ''; | ||
|
||
bool = /src/i.test(cssText) && cssText.indexOf(rule.split(' ')[0]) === 0; | ||
}); | ||
|
||
return bool; | ||
}; | ||
/*>>fontface*/ | ||
|
||
// CSS generated content detection | ||
tests['generatedcontent'] = function() { | ||
return Modernizr['generatedcontent']; | ||
var bool; | ||
|
||
injectElementWithStyles(['#modernizr:after{content:"',smile,'";visibility:hidden}'].join(''), function( node ) { | ||
bool = node.offsetHeight >= 1; | ||
}); | ||
|
||
return bool; | ||
}; | ||
|
||
|
||
|
This somehow disables native kinetic scrolling on iOS 6; scrolling still works but is not animated.
The scrollbar that usually appears is also not visible.