diff --git a/Gruntfile.js b/Gruntfile.js index 1a981d8ca5..640aef24c6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -95,6 +95,7 @@ module.exports = function( grunt ) { trailing: true, undef: true, unused: true, + indent: 2, globals: { Modernizr: true, DocumentTouch: true, @@ -105,7 +106,9 @@ module.exports = function( grunt ) { require: true }, ignores: [ - 'src/load.js' + 'src/load.js', + 'src/html5printshiv.js', + 'src/html5shiv.js' ] }, files: [ diff --git a/feature-detects/audio/loop.js b/feature-detects/audio/loop.js index 610da4b22a..e2508e1d77 100644 --- a/feature-detects/audio/loop.js +++ b/feature-detects/audio/loop.js @@ -6,5 +6,5 @@ } !*/ define(['Modernizr', 'createElement'], function( Modernizr, createElement ) { - Modernizr.addTest('audioloop', 'loop' in createElement('audio')); + Modernizr.addTest('audioloop', 'loop' in createElement('audio')); }); diff --git a/feature-detects/audio/preload.js b/feature-detects/audio/preload.js index 288b7abdc1..362f417f7b 100644 --- a/feature-detects/audio/preload.js +++ b/feature-detects/audio/preload.js @@ -6,5 +6,5 @@ } !*/ define(['Modernizr', 'createElement'], function( Modernizr, createElement ) { - Modernizr.addTest('audiopreload', 'preload' in createElement('audio')); + Modernizr.addTest('audiopreload', 'preload' in createElement('audio')); }); diff --git a/feature-detects/css/borderimage.js b/feature-detects/css/borderimage.js index cb1b127008..620e51321c 100644 --- a/feature-detects/css/borderimage.js +++ b/feature-detects/css/borderimage.js @@ -9,5 +9,5 @@ } !*/ define(['Modernizr', 'testAllProps'], function( Modernizr, testAllProps ) { - Modernizr.addTest('borderimage', testAllProps('borderImage', 'url() 1', true)); + Modernizr.addTest('borderimage', testAllProps('borderImage', 'url() 1', true)); }); diff --git a/feature-detects/css/checked.js b/feature-detects/css/checked.js index 92427e06ed..ef1fb59966 100644 --- a/feature-detects/css/checked.js +++ b/feature-detects/css/checked.js @@ -12,7 +12,7 @@ !*/ define(['Modernizr', 'createElement', 'testStyles'], function( Modernizr, createElement, testStyles ) { Modernizr.addTest('checked', function(){ - return testStyles('#modernizr {position:absolute} #modernizr input {margin-left:10px} #modernizr :checked {margin-left:20px;display:block}', function( elem ){ + return testStyles('#modernizr {position:absolute} #modernizr input {margin-left:10px} #modernizr :checked {margin-left:20px;display:block}', function( elem ){ var cb = createElement('input'); cb.setAttribute('type', 'checkbox'); cb.setAttribute('checked', 'checked'); diff --git a/feature-detects/css/fontface.js b/feature-detects/css/fontface.js index 214983ee67..cd94de1598 100644 --- a/feature-detects/css/fontface.js +++ b/feature-detects/css/fontface.js @@ -27,23 +27,23 @@ } !*/ define(['Modernizr', 'testStyles'], function( Modernizr, testStyles ) { - var blacklist = (function() { - var ua = navigator.userAgent; - var wkvers = ua.match( /applewebkit\/([0-9]+)/gi ) && parseFloat( RegExp.$1 ); - var webos = ua.match( /w(eb)?osbrowser/gi ); - var wppre8 = ua.match( /windows phone/gi ) && ua.match( /iemobile\/([0-9])+/gi ) && parseFloat( RegExp.$1 ) >= 9; - var oldandroid = wkvers < 533 && ua.match( /android/gi ); - return webos || oldandroid || wppre8; - }()); - if( blacklist ) { - Modernizr.addTest('fontface', false); - } else { - testStyles('@font-face {font-family:"font";src:url("https://")}', function( node, rule ) { - var style = document.getElementById('smodernizr'); - var sheet = style.sheet || style.styleSheet; - var cssText = sheet ? (sheet.cssRules && sheet.cssRules[0] ? sheet.cssRules[0].cssText : sheet.cssText || '') : ''; - var bool = /src/i.test(cssText) && cssText.indexOf(rule.split(' ')[0]) === 0; - Modernizr.addTest('fontface', bool); - }); - } + var blacklist = (function() { + var ua = navigator.userAgent; + var wkvers = ua.match( /applewebkit\/([0-9]+)/gi ) && parseFloat( RegExp.$1 ); + var webos = ua.match( /w(eb)?osbrowser/gi ); + var wppre8 = ua.match( /windows phone/gi ) && ua.match( /iemobile\/([0-9])+/gi ) && parseFloat( RegExp.$1 ) >= 9; + var oldandroid = wkvers < 533 && ua.match( /android/gi ); + return webos || oldandroid || wppre8; + }()); + if( blacklist ) { + Modernizr.addTest('fontface', false); + } else { + testStyles('@font-face {font-family:"font";src:url("https://")}', function( node, rule ) { + var style = document.getElementById('smodernizr'); + var sheet = style.sheet || style.styleSheet; + var cssText = sheet ? (sheet.cssRules && sheet.cssRules[0] ? sheet.cssRules[0].cssText : sheet.cssText || '') : ''; + var bool = /src/i.test(cssText) && cssText.indexOf(rule.split(' ')[0]) === 0; + Modernizr.addTest('fontface', bool); + }); + } }); diff --git a/feature-detects/css/shapes.js b/feature-detects/css/shapes.js index 37498ed468..fedf24b517 100644 --- a/feature-detects/css/shapes.js +++ b/feature-detects/css/shapes.js @@ -16,5 +16,5 @@ } !*/ define(['Modernizr', 'testAllProps'], function( Modernizr, testAllProps ) { - Modernizr.addTest('shapes', testAllProps('shapeOutside', 'content-box', true)); + Modernizr.addTest('shapes', testAllProps('shapeOutside', 'content-box', true)); }); diff --git a/feature-detects/css/siblinggeneral.js b/feature-detects/css/siblinggeneral.js index 1739a051d8..37e7739e5c 100644 --- a/feature-detects/css/siblinggeneral.js +++ b/feature-detects/css/siblinggeneral.js @@ -12,7 +12,7 @@ !*/ define(['Modernizr', 'createElement', 'testStyles'], function( Modernizr, createElement, testStyles ) { Modernizr.addTest('siblinggeneral', function(){ - return testStyles('#modernizr div {width:100px} #modernizr div ~ div {width:200px;display:block}', function( elem ) { + return testStyles('#modernizr div {width:100px} #modernizr div ~ div {width:200px;display:block}', function( elem ) { return elem.lastChild.offsetWidth == 200; }, 2); }); diff --git a/feature-detects/css/wrapflow.js b/feature-detects/css/wrapflow.js index c1c5558aaa..0b2f3fc03e 100644 --- a/feature-detects/css/wrapflow.js +++ b/feature-detects/css/wrapflow.js @@ -17,35 +17,35 @@ } !*/ define(['Modernizr', 'prefixed', 'docElement', 'createElement'], function( Modernizr, prefixed, docElement, createElement ) { - Modernizr.addTest('wrapflow', function () { - var prefixedProperty = prefixed('wrapFlow'); - if (!prefixedProperty) - return false; + Modernizr.addTest('wrapflow', function () { + var prefixedProperty = prefixed('wrapFlow'); + if (!prefixedProperty) + return false; - var wrapFlowProperty = prefixedProperty.replace(/([A-Z])/g, function (str, m1) { return '-' + m1.toLowerCase(); }).replace(/^ms-/, '-ms-'); + var wrapFlowProperty = prefixedProperty.replace(/([A-Z])/g, function (str, m1) { return '-' + m1.toLowerCase(); }).replace(/^ms-/, '-ms-'); - /* If the CSS parsing is there we need to determine if wrap-flow actually works to avoid false positive cases, e.g. the browser parses - the property, but it hasn't got the implementation for the functionality yet. */ - var container = createElement('div'); - var exclusion = createElement('div'); - var content = createElement('span'); + /* If the CSS parsing is there we need to determine if wrap-flow actually works to avoid false positive cases, e.g. the browser parses + the property, but it hasn't got the implementation for the functionality yet. */ + var container = createElement('div'); + var exclusion = createElement('div'); + var content = createElement('span'); - /* First we create a div with two adjacent divs inside it. The first div will be the content, the second div will be the exclusion area. - We use the "wrap-flow: end" property to test the actual behavior. (http://dev.w3.org/csswg/css3-exclusions/#wrap-flow-property) - The wrap-flow property is applied to the exclusion area what has a 50px left offset and a 100px width. - If the wrap-flow property is working correctly then the content should start after the exclusion area, so the content's left offset should be 150px. */ - exclusion.style.cssText = 'position: absolute; left: 50px; width: 100px; height: 20px;' + wrapFlowProperty + ':end;'; - content.innerText = 'X'; + /* First we create a div with two adjacent divs inside it. The first div will be the content, the second div will be the exclusion area. + We use the "wrap-flow: end" property to test the actual behavior. (http://dev.w3.org/csswg/css3-exclusions/#wrap-flow-property) + The wrap-flow property is applied to the exclusion area what has a 50px left offset and a 100px width. + If the wrap-flow property is working correctly then the content should start after the exclusion area, so the content's left offset should be 150px. */ + exclusion.style.cssText = 'position: absolute; left: 50px; width: 100px; height: 20px;' + wrapFlowProperty + ':end;'; + content.innerText = 'X'; - container.appendChild(exclusion); - container.appendChild(content); - docElement.appendChild(container); + container.appendChild(exclusion); + container.appendChild(content); + docElement.appendChild(container); - var leftOffset = content.offsetLeft; + var leftOffset = content.offsetLeft; - docElement.removeChild(container); - exclusion = content = container = undefined; + docElement.removeChild(container); + exclusion = content = container = undefined; - return (leftOffset == 150); - }); + return (leftOffset == 150); + }); }); diff --git a/feature-detects/es5/strictmode.js b/feature-detects/es5/strictmode.js index 9d420f67d2..0301fcb0a6 100644 --- a/feature-detects/es5/strictmode.js +++ b/feature-detects/es5/strictmode.js @@ -17,5 +17,5 @@ Check if browser implements ECMAScript 5 Object strict mode. */ define(['Modernizr'], function( Modernizr ) { - Modernizr.addTest('strictmode', (function(){ 'use strict'; return !this; })()); + Modernizr.addTest('strictmode', (function(){'use strict'; return !this; })()); }); diff --git a/feature-detects/flash.js b/feature-detects/flash.js index baa9781961..885e17215c 100644 --- a/feature-detects/flash.js +++ b/feature-detects/flash.js @@ -21,9 +21,9 @@ define(['Modernizr', 'createElement', 'docElement', 'addTest'], function( Modern bool.blocked = (result === 'blocked'); } addTest('flash', function() { return bool; }); - if (embed) { - docElement.removeChild(embed); - } + if (embed) { + docElement.removeChild(embed); + } }; var easy_detect; var activex; diff --git a/feature-detects/forms/fileinput.js b/feature-detects/forms/fileinput.js index 3686151f2a..f633c9a0e4 100644 --- a/feature-detects/forms/fileinput.js +++ b/feature-detects/forms/fileinput.js @@ -16,7 +16,7 @@ E.g. iOS < 6 and some android version don't support this define(['Modernizr', 'createElement'], function( Modernizr, createElement ) { Modernizr.addTest('fileinput', function() { if(navigator.userAgent.match(/(Android (1.0|1.1|1.5|1.6|2.0|2.1))|(Windows Phone (OS 7|8.0))|(XBLWP)|(ZuneWP)|(w(eb)?OSBrowser)|(webOS)|(Kindle\/(1.0|2.0|2.5|3.0))/)) { - return false; + return false; } var elem = createElement('input'); elem.type = 'file'; diff --git a/feature-detects/forms/validation.js b/feature-detects/forms/validation.js index a362b62566..74ceaa6982 100644 --- a/feature-detects/forms/validation.js +++ b/feature-detects/forms/validation.js @@ -16,52 +16,52 @@ the test can be combined: */ define(['Modernizr', 'createElement', 'docElement', 'testStyles'], function( Modernizr, createElement, docElement, testStyles ) { - Modernizr.addTest('formvalidation', function() { - var form = createElement('form'); - if ( !('checkValidity' in form) || !('addEventListener' in form) ) { - return false; - } - if ('reportValidity' in form) { - return true; - } - var invalidFired = false; - var input; - - Modernizr.formvalidationapi = true; + Modernizr.addTest('formvalidation', function() { + var form = createElement('form'); + if ( !('checkValidity' in form) || !('addEventListener' in form) ) { + return false; + } + if ('reportValidity' in form) { + return true; + } + var invalidFired = false; + var input; - // Prevent form from being submitted - form.addEventListener('submit', function(e) { - //Opera does not validate form, if submit is prevented - if ( !window.opera ) { - e.preventDefault(); - } - e.stopPropagation(); - }, false); + Modernizr.formvalidationapi = true; - // Calling form.submit() doesn't trigger interactive validation, - // use a submit button instead - //older opera browsers need a name attribute - form.innerHTML = ''; + // Prevent form from being submitted + form.addEventListener('submit', function(e) { + //Opera does not validate form, if submit is prevented + if ( !window.opera ) { + e.preventDefault(); + } + e.stopPropagation(); + }, false); - testStyles('#modernizr form{position:absolute;top:-99999em}', function( node ) { - node.appendChild(form); + // Calling form.submit() doesn't trigger interactive validation, + // use a submit button instead + //older opera browsers need a name attribute + form.innerHTML = ''; - input = form.getElementsByTagName('input')[0]; + testStyles('#modernizr form{position:absolute;top:-99999em}', function( node ) { + node.appendChild(form); - // Record whether "invalid" event is fired - input.addEventListener('invalid', function(e) { - invalidFired = true; - e.preventDefault(); - e.stopPropagation(); - }, false); + input = form.getElementsByTagName('input')[0]; - //Opera does not fully support the validationMessage property - Modernizr.formvalidationmessage = !!input.validationMessage; + // Record whether "invalid" event is fired + input.addEventListener('invalid', function(e) { + invalidFired = true; + e.preventDefault(); + e.stopPropagation(); + }, false); - // Submit form by clicking submit button - form.getElementsByTagName('button')[0].click(); - }); + //Opera does not fully support the validationMessage property + Modernizr.formvalidationmessage = !!input.validationMessage; - return invalidFired; + // Submit form by clicking submit button + form.getElementsByTagName('button')[0].click(); }); + + return invalidFired; + }); }); diff --git a/feature-detects/inputsearchevent.js b/feature-detects/inputsearchevent.js index d7c463d639..a6e4e493d8 100644 --- a/feature-detects/inputsearchevent.js +++ b/feature-detects/inputsearchevent.js @@ -19,5 +19,5 @@ */ define(['Modernizr', 'hasEvent'], function( Modernizr, hasEvent ) { - Modernizr.addTest('inputsearchevent', hasEvent('search')); + Modernizr.addTest('inputsearchevent', hasEvent('search')); }); diff --git a/feature-detects/pointerevents.js b/feature-detects/pointerevents.js index cbeda2ada9..e8ad05f151 100644 --- a/feature-detects/pointerevents.js +++ b/feature-detects/pointerevents.js @@ -26,15 +26,15 @@ define(['Modernizr', 'domPrefixes', 'hasEvent'], function( Modernizr, domPrefixe Modernizr.addTest('pointerevents', function () { // Cannot use `.prefixed()` for events, so test each prefix var bool = false, - i = domPrefixes.length; + i = domPrefixes.length; // Don't forget un-prefixed... bool = Modernizr.hasEvent('pointerdown'); while (i-- && !bool) { - if (hasEvent(domPrefixes[i] + 'pointerdown')) { - bool = true; - } + if (hasEvent(domPrefixes[i] + 'pointerdown')) { + bool = true; + } } return bool; }); diff --git a/feature-detects/url/data-uri.js b/feature-detects/url/data-uri.js index 84b0e00474..82161e4269 100644 --- a/feature-detects/url/data-uri.js +++ b/feature-detects/url/data-uri.js @@ -60,14 +60,14 @@ define(['Modernizr', 'addTest'], function( Modernizr, addTest ) { var datauriBig = new Image(); datauriBig.onerror = function() { - addTest('datauri', true); - Modernizr.datauri = new Boolean(true); - Modernizr.datauri.over32kb = false; + addTest('datauri', true); + Modernizr.datauri = new Boolean(true); + Modernizr.datauri.over32kb = false; }; datauriBig.onload = function() { - addTest('datauri', true); - Modernizr.datauri = new Boolean(true); - Modernizr.datauri.over32kb = (datauriBig.width == 1 && datauriBig.height == 1); + addTest('datauri', true); + Modernizr.datauri = new Boolean(true); + Modernizr.datauri.over32kb = (datauriBig.width == 1 && datauriBig.height == 1); }; var base64str = 'R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=='; diff --git a/feature-detects/video/loop.js b/feature-detects/video/loop.js index 5a7e9200e4..e08b8196e1 100644 --- a/feature-detects/video/loop.js +++ b/feature-detects/video/loop.js @@ -6,5 +6,5 @@ } !*/ define(['Modernizr', 'createElement'], function( Modernizr, createElement ) { - Modernizr.addTest('videoloop', 'loop' in createElement('video')); + Modernizr.addTest('videoloop', 'loop' in createElement('video')); }); diff --git a/feature-detects/video/preload.js b/feature-detects/video/preload.js index 9c62ef0d39..eb861c7653 100644 --- a/feature-detects/video/preload.js +++ b/feature-detects/video/preload.js @@ -6,5 +6,5 @@ } !*/ define(['Modernizr', 'createElement'], function( Modernizr, createElement ) { - Modernizr.addTest('videopreload', 'preload' in createElement('video')); + Modernizr.addTest('videopreload', 'preload' in createElement('video')); }); diff --git a/feature-detects/websockets/binary.js b/feature-detects/websockets/binary.js index fd304faf6d..0a156960f2 100644 --- a/feature-detects/websockets/binary.js +++ b/feature-detects/websockets/binary.js @@ -6,23 +6,23 @@ } !*/ define(['Modernizr'], function( Modernizr ) { - // binaryType is truthy if there is support.. returns "blob" in new-ish chrome. - // plus.google.com/115535723976198353696/posts/ERN6zYozENV - // github.com/Modernizr/Modernizr/issues/370 + // binaryType is truthy if there is support.. returns "blob" in new-ish chrome. + // plus.google.com/115535723976198353696/posts/ERN6zYozENV + // github.com/Modernizr/Modernizr/issues/370 - Modernizr.addTest('websocketsbinary', function() { - var protocol = 'https:'==location.protocol?'wss':'ws', - protoBin; + Modernizr.addTest('websocketsbinary', function() { + var protocol = 'https:'==location.protocol?'wss':'ws', + protoBin; - if('WebSocket' in window) { - if( protoBin = 'binaryType' in WebSocket.prototype ) { - return protoBin; - } - try { - return !!(new WebSocket(protocol+'://.').binaryType); - } catch (e){} - } + if('WebSocket' in window) { + if( protoBin = 'binaryType' in WebSocket.prototype ) { + return protoBin; + } + try { + return !!(new WebSocket(protocol+'://.').binaryType); + } catch (e){} + } - return false; - }); + return false; + }); }); diff --git a/lib/app.build.js b/lib/app.build.js index 2885c1339f..8128f73032 100644 --- a/lib/app.build.js +++ b/lib/app.build.js @@ -7,13 +7,11 @@ 'paths' : { 'test' : '../feature-detects' }, - modules : [ - { + modules : [{ 'name' : 'modernizr-build', 'include' : ['modernizr-init'], 'create' : true - } - ], + }], onBuildWrite: function (id, path, contents) { if ((/define\(.*?\{/).test(contents)) { //Remove AMD ceremony for use without require.js or almond.js diff --git a/lib/build.js b/lib/build.js index d8ec369f92..0af54d0a6e 100644 --- a/lib/build.js +++ b/lib/build.js @@ -49,7 +49,7 @@ module.exports = function (opts, callback) { } } -var build = cp.spawn(__dirname + '/../node_modules/.bin/' + 'grunt', ['build'], { + var build = cp.spawn(__dirname + '/../node_modules/.bin/' + 'grunt', ['build'], { stdio: verbose ? 'inherit' : [0, 'pipe', 2], cwd: localRoot }); diff --git a/src/domToHyphenated.js b/src/domToHyphenated.js index 318f5f6b5a..9e454995c6 100644 --- a/src/domToHyphenated.js +++ b/src/domToHyphenated.js @@ -1,9 +1,9 @@ define(function() { - // Helper function for e.g. boxSizing -> box-sizing - function domToHyphenated( name ) { - return name.replace(/([A-Z])/g, function(str, m1) { - return '-' + m1.toLowerCase(); - }).replace(/^ms-/, '-ms-'); - } - return domToHyphenated; + // Helper function for e.g. boxSizing -> box-sizing + function domToHyphenated( name ) { + return name.replace(/([A-Z])/g, function(str, m1) { + return '-' + m1.toLowerCase(); + }).replace(/^ms-/, '-ms-'); + } + return domToHyphenated; }); diff --git a/src/nativeTestProps.js b/src/nativeTestProps.js index c7c4354f39..a6f2eaec64 100644 --- a/src/nativeTestProps.js +++ b/src/nativeTestProps.js @@ -1,34 +1,34 @@ define(['injectElementWithStyles', 'domToHyphenated'], function ( injectElementWithStyles, domToHyphenated ) { - // Function to allow us to use native feature detection functionality if available. - // Accepts a list of property names and a single value - // Returns `undefined` if native detection not available - function nativeTestProps ( props, value ) { - var i = props.length; - // Start with the JS API: http://www.w3.org/TR/css3-conditional/#the-css-interface - if ('CSS' in window && 'supports' in window.CSS) { - // Try every prefixed variant of the property - while (i--) { - if (window.CSS.supports(domToHyphenated(props[i]), value)) { - return true; - } - } - return false; + // Function to allow us to use native feature detection functionality if available. + // Accepts a list of property names and a single value + // Returns `undefined` if native detection not available + function nativeTestProps ( props, value ) { + var i = props.length; + // Start with the JS API: http://www.w3.org/TR/css3-conditional/#the-css-interface + if ('CSS' in window && 'supports' in window.CSS) { + // Try every prefixed variant of the property + while (i--) { + if (window.CSS.supports(domToHyphenated(props[i]), value)) { + return true; } - // Otherwise fall back to at-rule (for FF 17 and Opera 12.x) - else if ('CSSSupportsRule' in window) { - // Build a condition string for every prefixed variant - var conditionText = []; - while (i--) { - conditionText.push('(' + domToHyphenated(props[i]) + ':' + value + ')'); - } - conditionText = conditionText.join(' or '); - return injectElementWithStyles('@supports (' + conditionText + ') { #modernizr { position: absolute; } }', function( node ) { - return (window.getComputedStyle ? - getComputedStyle(node, null) : - node.currentStyle)['position'] == 'absolute'; - }); - } - return undefined; + } + return false; + } + // Otherwise fall back to at-rule (for FF 17 and Opera 12.x) + else if ('CSSSupportsRule' in window) { + // Build a condition string for every prefixed variant + var conditionText = []; + while (i--) { + conditionText.push('(' + domToHyphenated(props[i]) + ':' + value + ')'); + } + conditionText = conditionText.join(' or '); + return injectElementWithStyles('@supports (' + conditionText + ') { #modernizr { position: absolute; } }', function( node ) { + return (window.getComputedStyle ? + getComputedStyle(node, null) : + node.currentStyle)['position'] == 'absolute'; + }); } - return nativeTestProps; + return undefined; + } + return nativeTestProps; }); diff --git a/src/testAllProps.js b/src/testAllProps.js index e73b32eb61..7becc3e6be 100644 --- a/src/testAllProps.js +++ b/src/testAllProps.js @@ -14,9 +14,9 @@ define(['ModernizrProto', 'testPropsAll'], function( ModernizrProto, testPropsAl * is supported when using non-native detection * (default: false) */ - function testAllProps (prop, value, skipValueTest) { - return testPropsAll(prop, undefined, undefined, value, skipValueTest); - } - ModernizrProto.testAllProps = testAllProps; - return testAllProps; + function testAllProps (prop, value, skipValueTest) { + return testPropsAll(prop, undefined, undefined, value, skipValueTest); + } + ModernizrProto.testAllProps = testAllProps; + return testAllProps; }); diff --git a/src/testPropsAll.js b/src/testPropsAll.js index 793ae6f83f..48f9b35eb9 100644 --- a/src/testPropsAll.js +++ b/src/testPropsAll.js @@ -1,31 +1,31 @@ define(['ModernizrProto', 'cssomPrefixes', 'is', 'testProps', 'domPrefixes', 'testDOMProps'], function( ModernizrProto, cssomPrefixes, is, testProps, domPrefixes, testDOMProps ) { - /** - * testPropsAll tests a list of DOM properties we want to check against. - * We specify literally ALL possible (known and/or likely) properties on - * the element including the non-vendor prefixed one, for forward- - * compatibility. - */ - function testPropsAll( prop, prefixed, elem, value, skipValueTest ) { + /** + * testPropsAll tests a list of DOM properties we want to check against. + * We specify literally ALL possible (known and/or likely) properties on + * the element including the non-vendor prefixed one, for forward- + * compatibility. + */ + function testPropsAll( prop, prefixed, elem, value, skipValueTest ) { - var ucProp = prop.charAt(0).toUpperCase() + prop.slice(1), - props = (prop + ' ' + cssomPrefixes.join(ucProp + ' ') + ucProp).split(' '); + var ucProp = prop.charAt(0).toUpperCase() + prop.slice(1), + props = (prop + ' ' + cssomPrefixes.join(ucProp + ' ') + ucProp).split(' '); - // did they call .prefixed('boxSizing') or are we just testing a prop? - if(is(prefixed, 'string') || is(prefixed, 'undefined')) { - return testProps(props, prefixed, value, skipValueTest); + // did they call .prefixed('boxSizing') or are we just testing a prop? + if(is(prefixed, 'string') || is(prefixed, 'undefined')) { + return testProps(props, prefixed, value, skipValueTest); - // otherwise, they called .prefixed('requestAnimationFrame', window[, elem]) - } else { - props = (prop + ' ' + (domPrefixes).join(ucProp + ' ') + ucProp).split(' '); - return testDOMProps(props, prefixed, elem); - } + // otherwise, they called .prefixed('requestAnimationFrame', window[, elem]) + } else { + props = (prop + ' ' + (domPrefixes).join(ucProp + ' ') + ucProp).split(' '); + return testDOMProps(props, prefixed, elem); } + } - // Modernizr.testAllProps() investigates whether a given style property, - // or any of its vendor-prefixed variants, is recognized - // Note that the property names must be provided in the camelCase variant. - // Modernizr.testAllProps('boxSizing') - ModernizrProto.testAllProps = testPropsAll; + // Modernizr.testAllProps() investigates whether a given style property, + // or any of its vendor-prefixed variants, is recognized + // Note that the property names must be provided in the camelCase variant. + // Modernizr.testAllProps('boxSizing') + ModernizrProto.testAllProps = testPropsAll; - return testPropsAll; + return testPropsAll; }); diff --git a/test.html b/test.html deleted file mode 100644 index 10f29db719..0000000000 --- a/test.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - what - - - - - diff --git a/test/js/dumpdata.js b/test/js/dumpdata.js index df155128a2..d1790eef1b 100644 --- a/test/js/dumpdata.js +++ b/test/js/dumpdata.js @@ -2,32 +2,32 @@ function dumpModernizr(){ var str = ''; dumpModernizr.old = dumpModernizr.old || {}; - for (var prop in Modernizr) { - - // skip previously done ones. - if (dumpModernizr.old[prop]) continue; - else dumpModernizr.old[prop] = true; - - if (typeof Modernizr[prop] === 'function') continue; - // skip unit test items - if (/^test/.test(prop)) continue; - - if (~TEST.inputs.indexOf(prop)) { - str += '
  • '+prop+'{}
  • '; - } else { - str += '
  • ' + prop + ': ' + Modernizr[prop] + '
  • '; + for (var prop in Modernizr) { + + // skip previously done ones. + if (dumpModernizr.old[prop]) continue; + else dumpModernizr.old[prop] = true; + + if (typeof Modernizr[prop] === 'function') continue; + // skip unit test items + if (/^test/.test(prop)) continue; + + if (~TEST.inputs.indexOf(prop)) { + str += '
  • '+prop+'{}
  • '; + } else { + str += '
  • ' + prop + ': ' + Modernizr[prop] + '
  • '; + } } return str; } function resultsToDOM(){ var modOutput = document.createElement('div'), - ref = document.getElementById('qunit-testresult') || document.getElementById('qunit-tests'); + ref = document.getElementById('qunit-testresult') || document.getElementById('qunit-tests'); modOutput.className = 'output'; modOutput.innerHTML = dumpModernizr(); @@ -38,6 +38,11 @@ function resultsToDOM(){ document.getElementsByTagName('textarea')[0].innerHTML = JSON.stringify(Modernizr); } -/* uno */ resultsToDOM(); -/* dos */ setTimeout(resultsToDOM, 5e3); -/* tres */ setTimeout(resultsToDOM, 15e3); +/* uno */ +resultsToDOM(); + +/* dos */ +setTimeout(resultsToDOM, 5e3); + +/* tres */ +setTimeout(resultsToDOM, 15e3); diff --git a/test/js/setup.js b/test/js/setup.js index ba1e8dc7ac..0d5547afc6 100644 --- a/test/js/setup.js +++ b/test/js/setup.js @@ -1,14 +1,14 @@ // Avoid `console` errors in browsers that lack a console if (!(window.console && console.log)) { - (function() { - var noop = function() {}; - var methods = ['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'markTimeline', 'profile', 'profileEnd', 'markTimeline', 'table', 'time', 'timeEnd', 'timeStamp', 'trace', 'warn']; - var length = methods.length; - var console = window.console = {}; - while (length--) { - console[methods[length]] = noop; - } - }()); + (function() { + var noop = function() {}; + var methods = ['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'markTimeline', 'profile', 'profileEnd', 'markTimeline', 'table', 'time', 'timeEnd', 'timeStamp', 'trace', 'warn']; + var length = methods.length; + var console = window.console = {}; + while (length--) { + console[methods[length]] = noop; + } + }()); } // test helper object @@ -21,21 +21,21 @@ window.TEST = { extraclass: ['js'], privates : ['_enableHTML5','_version','_fontfaceready'], deprecated : [ - { oldish : 'crosswindowmessaging', newish : 'postmessage'}, - { oldish : 'historymanagement', newish : 'history'} - ], + { oldish : 'crosswindowmessaging', newish : 'postmessage'}, + { oldish : 'historymanagement', newish : 'history'} + ], // utility methods inArray: function(elem, array) { - if (array.indexOf) { - return array.indexOf(elem); + if (array.indexOf) { + return array.indexOf(elem); + } + for (var i = 0, length = array.length; i < length; i++) { + if (array[i] === elem) { + return i; } - for (var i = 0, length = array.length; i < length; i++) { - if (array[i] === elem) { - return i; - } - } - return -1; + } + return -1; }, trim : function(str){ return str.replace(/^\s*/, '').replace(/\s*$/, ''); diff --git a/test/js/unit-caniuse.js b/test/js/unit-caniuse.js index 1e737d9f5c..a12c4df0e3 100644 --- a/test/js/unit-caniuse.js +++ b/test/js/unit-caniuse.js @@ -1,7 +1,7 @@ /*globals uaparse, JSONSelect, ok, equal, module, test */ var myscript = document.createElement('script'), - ref = document.getElementsByTagName('script')[0]; +ref = document.getElementsByTagName('script')[0]; myscript.src = 'http://caniuse.com/jsonp.php?callback=caniusecb'; @@ -117,12 +117,12 @@ window.caniusecb = function(scriptdata) { var testdata = scriptdata.data, - // parse the current UA with uaparser - ua = uaparse(navigator.userAgent), + // parse the current UA with uaparser + ua = uaparse(navigator.userAgent), - // match the UA from uaparser into the browser used by caniuse - browserKey = JSONSelect.match('.agents .browser', scriptdata).indexOf(ua.family), - currBrowser = Object.keys(scriptdata.agents)[browserKey]; + // match the UA from uaparser into the browser used by caniuse + browserKey = JSONSelect.match('.agents .browser', scriptdata).indexOf(ua.family), + currBrowser = Object.keys(scriptdata.agents)[browserKey]; // So Phantom doesn't kill the caniuse.com matching exit out as it's useless anyway within PhantomJS if(navigator.userAgent.indexOf('PhantomJS') != -1) { @@ -148,9 +148,9 @@ window.caniusecb = function(scriptdata) { // if caniuse gave us a 'partial', lets let it pass with a note. if (o.ciuresult == 'a'){ return ok(true, - o.browser + o.version + ': Caniuse reported partial support for ' + o.ciufeature + - '. So.. Modernizr\'s ' + o.result + ' is good enough...' - ); + o.browser + o.version + ': Caniuse reported partial support for ' + o.ciufeature + + '. So.. Modernizr\'s ' + o.result + ' is good enough...' + ); } @@ -161,17 +161,17 @@ window.caniusecb = function(scriptdata) { // where we actually do most our assertions equal(o.result, ciubool, - o.browser + o.version + ': Caniuse result for ' + o.ciufeature + - ' matches Modernizr\'s ' + (o.fp ? '*false positive*' : 'result') + ' for ' + o.feature - ); + o.browser + o.version + ': Caniuse result for ' + o.ciufeature + + ' matches Modernizr\'s ' + (o.fp ? '*false positive*' : 'result') + ' for ' + o.feature + ); } module('caniuse.com data matches', { - setup:function() { - }, - teardown:function() { - } + setup:function() { + }, + teardown:function() { + } }); @@ -192,15 +192,15 @@ window.caniusecb = function(scriptdata) { // let's get our versions in order.. var minorver = ua.minor && // caniuse doesn't use two digit minors - ua.minor.toString().replace(/(\d)\d$/,'$1'), // but opera does. + ua.minor.toString().replace(/(\d)\d$/,'$1'), // but opera does. - majorminor = (ua.major + '.' + minorver) - // opera gets grouped in some cases by caniuse - .replace(/(9\.(6|5))/ , ua.family == 'opera' ? '9.5-9.6' : '$1') - .replace(/(10\.(0|1))/, ua.family == 'opera' ? '10.0-10.1' : '$1'), + majorminor = (ua.major + '.' + minorver) + // opera gets grouped in some cases by caniuse + .replace(/(9\.(6|5))/ , ua.family == 'opera' ? '9.5-9.6' : '$1') + .replace(/(10\.(0|1))/, ua.family == 'opera' ? '10.0-10.1' : '$1'), - mmResult = browserResults[majorminor], - mResult = browserResults[ua.major]; + mmResult = browserResults[majorminor], + mResult = browserResults[ua.major]; // check it against the major.minor: eg. FF 3.6 diff --git a/test/js/unit.js b/test/js/unit.js index be482b488e..a33895a65c 100644 --- a/test/js/unit.js +++ b/test/js/unit.js @@ -8,10 +8,10 @@ if(navigator.userAgent.indexOf('PhantomJS') === -1) { var classes = TEST.trim(document.documentElement.className).split(/\s+/); module('Basics', { - setup:function() { - }, - teardown:function() { - } + setup:function() { + }, + teardown:function() { + } }); test('globals set up', function() { @@ -23,7 +23,7 @@ test('bind is implemented', function() { ok(Function.prototype.bind, 'bind is a member of Function.prototype'); var a = function(){ - return this.modernizr; + return this.modernizr; }; a = a.bind({modernizr: 'just awsome'}); @@ -35,9 +35,8 @@ test('bind is implemented', function() { var result; - function F(x, y) - { - result = this + ' -> x:' + x + ', y:' + y; + function F(x, y) { + result = this + ' -> x:' + x + ', y:' + y; } var G = F.bind('"a"', '"b"'); @@ -122,10 +121,10 @@ test('html shim worked', function(){ module('Modernizr classes and bools', { - setup:function() { - }, - teardown:function() { - } + setup:function() { + }, + teardown:function() { + } }); @@ -272,10 +271,10 @@ test('Modernizr results match expected values',function(){ module('Modernizr\'s API methods', { - setup:function() { - }, - teardown:function() { - } + setup:function() { + }, + teardown:function() { + } }); test('Modernizr.addTest()',22,function(){ @@ -314,8 +313,8 @@ test('Modernizr.addTest()',22,function(){ Modernizr.addTest('testcamelCase',function(){ - return true; - }); + return true; + }); ok(docEl.className.indexOf(' testcamelCase') === -1, 'camelCase test name toLowerCase()\'d'); @@ -390,15 +389,15 @@ test('Modernizr.mq: media query testing',function(){ return function( query ) { if ( !( query in cache ) ) { var styleBlock = document.createElement('style'), - cssrule = '@media ' + query + ' { #jquery-mediatest { position:absolute; } }'; - //must set type for IE! - styleBlock.type = 'text/css'; - if (styleBlock.styleSheet){ - styleBlock.styleSheet.cssText = cssrule; - } - else { - styleBlock.appendChild(document.createTextNode(cssrule)); - } + cssrule = '@media ' + query + ' { #jquery-mediatest { position:absolute; } }'; + //must set type for IE! + styleBlock.type = 'text/css'; + if (styleBlock.styleSheet){ + styleBlock.styleSheet.cssText = cssrule; + } + else { + styleBlock.appendChild(document.createTextNode(cssrule)); + } $html.prepend( fakeBody ).prepend( styleBlock ); cache[ query ] = testDiv.css( 'position' ) === 'absolute'; @@ -448,11 +447,11 @@ test('Modernizr.testStyles()',function(){ var style = '#modernizr{ width: 9px; height: 4px; font-size: 0; color: papayawhip; }'; - Modernizr.testStyles(style, function(elem, rule){ - equal(style, rule, 'rule passsed back matches what i gave it.'); - equal(elem.offsetWidth, 9, 'width was set through the style'); - equal(elem.offsetHeight, 4, 'height was set through the style'); - equal(elem.id, 'modernizr', 'element is indeed the modernizr element'); + Modernizr.testStyles(style, function(elem, rule) { + equal(style, rule, 'rule passsed back matches what i gave it.'); + equal(elem.offsetWidth, 9, 'width was set through the style'); + equal(elem.offsetHeight, 4, 'height was set through the style'); + equal(elem.id, 'modernizr', 'element is indeed the modernizr element'); }); });