Path: blob/master/6-Selenium/phantomjs/examples/modernizr.js
164 views
/*!1* Modernizr v2.8.22* www.modernizr.com3*4* Copyright (c) Faruk Ates, Paul Irish, Alex Sexton5* Available under the BSD and MIT licenses: www.modernizr.com/license/6*/78/*9* Modernizr tests which native CSS3 and HTML5 features are available in10* the current UA and makes the results available to you in two ways:11* as properties on a global Modernizr object, and as classes on the12* <html> element. This information allows you to progressively enhance13* your pages with a granular level of control over the experience.14*15* Modernizr has an optional (not included) conditional resource loader16* called Modernizr.load(), based on Yepnope.js (yepnopejs.com).17* To get a build that includes Modernizr.load(), as well as choosing18* which tests to include, go to www.modernizr.com/download/19*20* Authors Faruk Ates, Paul Irish, Alex Sexton21* Contributors Ryan Seddon, Ben Alman22*/2324window.Modernizr = (function( window, document, undefined ) {2526var version = '2.8.2',2728Modernizr = {},2930/*>>cssclasses*/31// option for enabling the HTML classes to be added32enableClasses = true,33/*>>cssclasses*/3435docElement = document.documentElement,3637/**38* Create our "modernizr" element that we do most feature tests on.39*/40mod = 'modernizr',41modElem = document.createElement(mod),42mStyle = modElem.style,4344/**45* Create the input element for various Web Forms feature tests.46*/47inputElem /*>>inputelem*/ = document.createElement('input') /*>>inputelem*/ ,4849/*>>smile*/50smile = ':)',51/*>>smile*/5253toString = {}.toString,5455// TODO :: make the prefixes more granular56/*>>prefixes*/57// List of property values to set for css tests. See ticket #2158prefixes = ' -webkit- -moz- -o- -ms- '.split(' '),59/*>>prefixes*/6061/*>>domprefixes*/62// Following spec is to expose vendor-specific style properties as:63// elem.style.WebkitBorderRadius64// and the following would be incorrect:65// elem.style.webkitBorderRadius6667// Webkit ghosts their properties in lowercase but Opera & Moz do not.68// Microsoft uses a lowercase `ms` instead of the correct `Ms` in IE8+69// erik.eae.net/archives/2008/03/10/21.48.10/7071// More here: github.com/Modernizr/Modernizr/issues/issue/2172omPrefixes = 'Webkit Moz O ms',7374cssomPrefixes = omPrefixes.split(' '),7576domPrefixes = omPrefixes.toLowerCase().split(' '),77/*>>domprefixes*/7879/*>>ns*/80ns = {'svg': 'http://www.w3.org/2000/svg'},81/*>>ns*/8283tests = {},84inputs = {},85attrs = {},8687classes = [],8889slice = classes.slice,9091featureName, // used in testing loop929394/*>>teststyles*/95// Inject element with style element and some CSS rules96injectElementWithStyles = function( rule, callback, nodes, testnames ) {9798var style, ret, node, docOverflow,99div = document.createElement('div'),100// After page load injecting a fake body doesn't work so check if body exists101body = document.body,102// IE6 and 7 won't return offsetWidth or offsetHeight unless it's in the body element, so we fake it.103fakeBody = body || document.createElement('body');104105if ( parseInt(nodes, 10) ) {106// In order not to give false positives we create a node for each test107// This also allows the method to scale for unspecified uses108while ( nodes-- ) {109node = document.createElement('div');110node.id = testnames ? testnames[nodes] : mod + (nodes + 1);111div.appendChild(node);112}113}114115// <style> elements in IE6-9 are considered 'NoScope' elements and therefore will be removed116// when injected with innerHTML. To get around this you need to prepend the 'NoScope' element117// with a 'scoped' element, in our case the soft-hyphen entity as it won't mess with our measurements.118// msdn.microsoft.com/en-us/library/ms533897%28VS.85%29.aspx119// Documents served as xml will throw if using ­ so use xml friendly encoded version. See issue #277120style = ['­','<style id="s', mod, '">', rule, '</style>'].join('');121div.id = mod;122// IE6 will false positive on some tests due to the style element inside the test div somehow interfering offsetHeight, so insert it into body or fakebody.123// Opera will act all quirky when injecting elements in documentElement when page is served as xml, needs fakebody too. #270124(body ? div : fakeBody).innerHTML += style;125fakeBody.appendChild(div);126if ( !body ) {127//avoid crashing IE8, if background image is used128fakeBody.style.background = '';129//Safari 5.13/5.1.4 OSX stops loading if ::-webkit-scrollbar is used and scrollbars are visible130fakeBody.style.overflow = 'hidden';131docOverflow = docElement.style.overflow;132docElement.style.overflow = 'hidden';133docElement.appendChild(fakeBody);134}135136ret = callback(div, rule);137// If this is done after page load we don't want to remove the body so check if body exists138if ( !body ) {139fakeBody.parentNode.removeChild(fakeBody);140docElement.style.overflow = docOverflow;141} else {142div.parentNode.removeChild(div);143}144145return !!ret;146147},148/*>>teststyles*/149150/*>>mq*/151// adapted from matchMedia polyfill152// by Scott Jehl and Paul Irish153// gist.github.com/786768154testMediaQuery = function( mq ) {155156var matchMedia = window.matchMedia || window.msMatchMedia;157if ( matchMedia ) {158return matchMedia(mq) && matchMedia(mq).matches || false;159}160161var bool;162163injectElementWithStyles('@media ' + mq + ' { #' + mod + ' { position: absolute; } }', function( node ) {164bool = (window.getComputedStyle ?165getComputedStyle(node, null) :166node.currentStyle)['position'] == 'absolute';167});168169return bool;170171},172/*>>mq*/173174175/*>>hasevent*/176//177// isEventSupported determines if a given element supports the given event178// kangax.github.com/iseventsupported/179//180// The following results are known incorrects:181// Modernizr.hasEvent("webkitTransitionEnd", elem) // false negative182// Modernizr.hasEvent("textInput") // in Webkit. github.com/Modernizr/Modernizr/issues/333183// ...184isEventSupported = (function() {185186var TAGNAMES = {187'select': 'input', 'change': 'input',188'submit': 'form', 'reset': 'form',189'error': 'img', 'load': 'img', 'abort': 'img'190};191192function isEventSupported( eventName, element ) {193194element = element || document.createElement(TAGNAMES[eventName] || 'div');195eventName = 'on' + eventName;196197// When using `setAttribute`, IE skips "unload", WebKit skips "unload" and "resize", whereas `in` "catches" those198var isSupported = eventName in element;199200if ( !isSupported ) {201// If it has no `setAttribute` (i.e. doesn't implement Node interface), try generic element202if ( !element.setAttribute ) {203element = document.createElement('div');204}205if ( element.setAttribute && element.removeAttribute ) {206element.setAttribute(eventName, '');207isSupported = is(element[eventName], 'function');208209// If property was created, "remove it" (by setting value to `undefined`)210if ( !is(element[eventName], 'undefined') ) {211element[eventName] = undefined;212}213element.removeAttribute(eventName);214}215}216217element = null;218return isSupported;219}220return isEventSupported;221})(),222/*>>hasevent*/223224// TODO :: Add flag for hasownprop ? didn't last time225226// hasOwnProperty shim by kangax needed for Safari 2.0 support227_hasOwnProperty = ({}).hasOwnProperty, hasOwnProp;228229if ( !is(_hasOwnProperty, 'undefined') && !is(_hasOwnProperty.call, 'undefined') ) {230hasOwnProp = function (object, property) {231return _hasOwnProperty.call(object, property);232};233}234else {235hasOwnProp = function (object, property) { /* yes, this can give false positives/negatives, but most of the time we don't care about those */236return ((property in object) && is(object.constructor.prototype[property], 'undefined'));237};238}239240// Adapted from ES5-shim https://github.com/kriskowal/es5-shim/blob/master/es5-shim.js241// es5.github.com/#x15.3.4.5242243if (!Function.prototype.bind) {244Function.prototype.bind = function bind(that) {245246var target = this;247248if (typeof target != "function") {249throw new TypeError();250}251252var args = slice.call(arguments, 1),253bound = function () {254255if (this instanceof bound) {256257var F = function(){};258F.prototype = target.prototype;259var self = new F();260261var result = target.apply(262self,263args.concat(slice.call(arguments))264);265if (Object(result) === result) {266return result;267}268return self;269270} else {271272return target.apply(273that,274args.concat(slice.call(arguments))275);276277}278279};280281return bound;282};283}284285/**286* setCss applies given styles to the Modernizr DOM node.287*/288function setCss( str ) {289mStyle.cssText = str;290}291292/**293* setCssAll extrapolates all vendor-specific css strings.294*/295function setCssAll( str1, str2 ) {296return setCss(prefixes.join(str1 + ';') + ( str2 || '' ));297}298299/**300* is returns a boolean for if typeof obj is exactly type.301*/302function is( obj, type ) {303return typeof obj === type;304}305306/**307* contains returns a boolean for if substr is found within str.308*/309function contains( str, substr ) {310return !!~('' + str).indexOf(substr);311}312313/*>>testprop*/314315// testProps is a generic CSS / DOM property test.316317// In testing support for a given CSS property, it's legit to test:318// `elem.style[styleName] !== undefined`319// If the property is supported it will return an empty string,320// if unsupported it will return undefined.321322// We'll take advantage of this quick test and skip setting a style323// on our modernizr element, but instead just testing undefined vs324// empty string.325326// Because the testing of the CSS property names (with "-", as327// opposed to the camelCase DOM properties) is non-portable and328// non-standard but works in WebKit and IE (but not Gecko or Opera),329// we explicitly reject properties with dashes so that authors330// developing in WebKit or IE first don't end up with331// browser-specific content by accident.332333function testProps( props, prefixed ) {334for ( var i in props ) {335var prop = props[i];336if ( !contains(prop, "-") && mStyle[prop] !== undefined ) {337return prefixed == 'pfx' ? prop : true;338}339}340return false;341}342/*>>testprop*/343344// TODO :: add testDOMProps345/**346* testDOMProps is a generic DOM property test; if a browser supports347* a certain property, it won't return undefined for it.348*/349function testDOMProps( props, obj, elem ) {350for ( var i in props ) {351var item = obj[props[i]];352if ( item !== undefined) {353354// return the property name as a string355if (elem === false) return props[i];356357// let's bind a function358if (is(item, 'function')){359// default to autobind unless override360return item.bind(elem || obj);361}362363// return the unbound function or obj or value364return item;365}366}367return false;368}369370/*>>testallprops*/371/**372* testPropsAll tests a list of DOM properties we want to check against.373* We specify literally ALL possible (known and/or likely) properties on374* the element including the non-vendor prefixed one, for forward-375* compatibility.376*/377function testPropsAll( prop, prefixed, elem ) {378379var ucProp = prop.charAt(0).toUpperCase() + prop.slice(1),380props = (prop + ' ' + cssomPrefixes.join(ucProp + ' ') + ucProp).split(' ');381382// did they call .prefixed('boxSizing') or are we just testing a prop?383if(is(prefixed, "string") || is(prefixed, "undefined")) {384return testProps(props, prefixed);385386// otherwise, they called .prefixed('requestAnimationFrame', window[, elem])387} else {388props = (prop + ' ' + (domPrefixes).join(ucProp + ' ') + ucProp).split(' ');389return testDOMProps(props, prefixed, elem);390}391}392/*>>testallprops*/393394395/**396* Tests397* -----398*/399400// The *new* flexbox401// dev.w3.org/csswg/css3-flexbox402403tests['flexbox'] = function() {404return testPropsAll('flexWrap');405};406407// The *old* flexbox408// www.w3.org/TR/2009/WD-css3-flexbox-20090723/409410tests['flexboxlegacy'] = function() {411return testPropsAll('boxDirection');412};413414// On the S60 and BB Storm, getContext exists, but always returns undefined415// so we actually have to call getContext() to verify416// github.com/Modernizr/Modernizr/issues/issue/97/417418tests['canvas'] = function() {419var elem = document.createElement('canvas');420return !!(elem.getContext && elem.getContext('2d'));421};422423tests['canvastext'] = function() {424return !!(Modernizr['canvas'] && is(document.createElement('canvas').getContext('2d').fillText, 'function'));425};426427// webk.it/70117 is tracking a legit WebGL feature detect proposal428429// We do a soft detect which may false positive in order to avoid430// an expensive context creation: bugzil.la/732441431432tests['webgl'] = function() {433return !!window.WebGLRenderingContext;434};435436/*437* The Modernizr.touch test only indicates if the browser supports438* touch events, which does not necessarily reflect a touchscreen439* device, as evidenced by tablets running Windows 7 or, alas,440* the Palm Pre / WebOS (touch) phones.441*442* Additionally, Chrome (desktop) used to lie about its support on this,443* but that has since been rectified: crbug.com/36415444*445* We also test for Firefox 4 Multitouch Support.446*447* For more info, see: modernizr.github.com/Modernizr/touch.html448*/449450tests['touch'] = function() {451var bool;452453if(('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) {454bool = true;455} else {456injectElementWithStyles(['@media (',prefixes.join('touch-enabled),('),mod,')','{#modernizr{top:9px;position:absolute}}'].join(''), function( node ) {457bool = node.offsetTop === 9;458});459}460461return bool;462};463464465// geolocation is often considered a trivial feature detect...466// Turns out, it's quite tricky to get right:467//468// Using !!navigator.geolocation does two things we don't want. It:469// 1. Leaks memory in IE9: github.com/Modernizr/Modernizr/issues/513470// 2. Disables page caching in WebKit: webk.it/43956471//472// Meanwhile, in Firefox < 8, an about:config setting could expose473// a false positive that would throw an exception: bugzil.la/688158474475tests['geolocation'] = function() {476return 'geolocation' in navigator;477};478479480tests['postmessage'] = function() {481return !!window.postMessage;482};483484485// Chrome incognito mode used to throw an exception when using openDatabase486// It doesn't anymore.487tests['websqldatabase'] = function() {488return !!window.openDatabase;489};490491// Vendors had inconsistent prefixing with the experimental Indexed DB:492// - Webkit's implementation is accessible through webkitIndexedDB493// - Firefox shipped moz_indexedDB before FF4b9, but since then has been mozIndexedDB494// For speed, we don't test the legacy (and beta-only) indexedDB495tests['indexedDB'] = function() {496return !!testPropsAll("indexedDB", window);497};498499// documentMode logic from YUI to filter out IE8 Compat Mode500// which false positives.501tests['hashchange'] = function() {502return isEventSupported('hashchange', window) && (document.documentMode === undefined || document.documentMode > 7);503};504505// Per 1.6:506// This used to be Modernizr.historymanagement but the longer507// name has been deprecated in favor of a shorter and property-matching one.508// The old API is still available in 1.6, but as of 2.0 will throw a warning,509// and in the first release thereafter disappear entirely.510tests['history'] = function() {511return !!(window.history && history.pushState);512};513514tests['draganddrop'] = function() {515var div = document.createElement('div');516return ('draggable' in div) || ('ondragstart' in div && 'ondrop' in div);517};518519// FF3.6 was EOL'ed on 4/24/12, but the ESR version of FF10520// will be supported until FF19 (2/12/13), at which time, ESR becomes FF17.521// FF10 still uses prefixes, so check for it until then.522// for more ESR info, see: mozilla.org/en-US/firefox/organizations/faq/523tests['websockets'] = function() {524return 'WebSocket' in window || 'MozWebSocket' in window;525};526527528// css-tricks.com/rgba-browser-support/529tests['rgba'] = function() {530// Set an rgba() color and check the returned value531532setCss('background-color:rgba(150,255,150,.5)');533534return contains(mStyle.backgroundColor, 'rgba');535};536537tests['hsla'] = function() {538// Same as rgba(), in fact, browsers re-map hsla() to rgba() internally,539// except IE9 who retains it as hsla540541setCss('background-color:hsla(120,40%,100%,.5)');542543return contains(mStyle.backgroundColor, 'rgba') || contains(mStyle.backgroundColor, 'hsla');544};545546tests['multiplebgs'] = function() {547// Setting multiple images AND a color on the background shorthand property548// and then querying the style.background property value for the number of549// occurrences of "url(" is a reliable method for detecting ACTUAL support for this!550551setCss('background:url(https://),url(https://),red url(https://)');552553// If the UA supports multiple backgrounds, there should be three occurrences554// of the string "url(" in the return value for elemStyle.background555556return (/(url\s*\(.*?){3}/).test(mStyle.background);557};558559560561// this will false positive in Opera Mini562// github.com/Modernizr/Modernizr/issues/396563564tests['backgroundsize'] = function() {565return testPropsAll('backgroundSize');566};567568tests['borderimage'] = function() {569return testPropsAll('borderImage');570};571572573// Super comprehensive table about all the unique implementations of574// border-radius: muddledramblings.com/table-of-css3-border-radius-compliance575576tests['borderradius'] = function() {577return testPropsAll('borderRadius');578};579580// WebOS unfortunately false positives on this test.581tests['boxshadow'] = function() {582return testPropsAll('boxShadow');583};584585// FF3.0 will false positive on this test586tests['textshadow'] = function() {587return document.createElement('div').style.textShadow === '';588};589590591tests['opacity'] = function() {592// Browsers that actually have CSS Opacity implemented have done so593// according to spec, which means their return values are within the594// range of [0.0,1.0] - including the leading zero.595596setCssAll('opacity:.55');597598// The non-literal . in this regex is intentional:599// German Chrome returns this value as 0,55600// github.com/Modernizr/Modernizr/issues/#issue/59/comment/516632601return (/^0.55$/).test(mStyle.opacity);602};603604605// Note, Android < 4 will pass this test, but can only animate606// a single property at a time607// goo.gl/v3V4Gp608tests['cssanimations'] = function() {609return testPropsAll('animationName');610};611612613tests['csscolumns'] = function() {614return testPropsAll('columnCount');615};616617618tests['cssgradients'] = function() {619/**620* For CSS Gradients syntax, please see:621* webkit.org/blog/175/introducing-css-gradients/622* developer.mozilla.org/en/CSS/-moz-linear-gradient623* developer.mozilla.org/en/CSS/-moz-radial-gradient624* dev.w3.org/csswg/css3-images/#gradients-625*/626627var str1 = 'background-image:',628str2 = 'gradient(linear,left top,right bottom,from(#9f9),to(white));',629str3 = 'linear-gradient(left top,#9f9, white);';630631setCss(632// legacy webkit syntax (FIXME: remove when syntax not in use anymore)633(str1 + '-webkit- '.split(' ').join(str2 + str1) +634// standard syntax // trailing 'background-image:'635prefixes.join(str3 + str1)).slice(0, -str1.length)636);637638return contains(mStyle.backgroundImage, 'gradient');639};640641642tests['cssreflections'] = function() {643return testPropsAll('boxReflect');644};645646647tests['csstransforms'] = function() {648return !!testPropsAll('transform');649};650651652tests['csstransforms3d'] = function() {653654var ret = !!testPropsAll('perspective');655656// Webkit's 3D transforms are passed off to the browser's own graphics renderer.657// It works fine in Safari on Leopard and Snow Leopard, but not in Chrome in658// some conditions. As a result, Webkit typically recognizes the syntax but659// will sometimes throw a false positive, thus we must do a more thorough check:660if ( ret && 'webkitPerspective' in docElement.style ) {661662// Webkit allows this media query to succeed only if the feature is enabled.663// `@media (transform-3d),(-webkit-transform-3d){ ... }`664injectElementWithStyles('@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}', function( node, rule ) {665ret = node.offsetLeft === 9 && node.offsetHeight === 3;666});667}668return ret;669};670671672tests['csstransitions'] = function() {673return testPropsAll('transition');674};675676677/*>>fontface*/678// @font-face detection routine by Diego Perini679// javascript.nwbox.com/CSSSupport/680681// false positives:682// WebOS github.com/Modernizr/Modernizr/issues/342683// WP7 github.com/Modernizr/Modernizr/issues/538684tests['fontface'] = function() {685var bool;686687injectElementWithStyles('@font-face {font-family:"font";src:url("https://")}', function( node, rule ) {688var style = document.getElementById('smodernizr'),689sheet = style.sheet || style.styleSheet,690cssText = sheet ? (sheet.cssRules && sheet.cssRules[0] ? sheet.cssRules[0].cssText : sheet.cssText || '') : '';691692bool = /src/i.test(cssText) && cssText.indexOf(rule.split(' ')[0]) === 0;693});694695return bool;696};697/*>>fontface*/698699// CSS generated content detection700tests['generatedcontent'] = function() {701var bool;702703injectElementWithStyles(['#',mod,'{font:0/0 a}#',mod,':after{content:"',smile,'";visibility:hidden;font:3px/1 a}'].join(''), function( node ) {704bool = node.offsetHeight >= 3;705});706707return bool;708};709710711712// These tests evaluate support of the video/audio elements, as well as713// testing what types of content they support.714//715// We're using the Boolean constructor here, so that we can extend the value716// e.g. Modernizr.video // true717// Modernizr.video.ogg // 'probably'718//719// Codec values from : github.com/NielsLeenheer/html5test/blob/9106a8/index.html#L845720// thx to NielsLeenheer and zcorpan721722// Note: in some older browsers, "no" was a return value instead of empty string.723// It was live in FF3.5.0 and 3.5.1, but fixed in 3.5.2724// It was also live in Safari 4.0.0 - 4.0.4, but fixed in 4.0.5725726tests['video'] = function() {727var elem = document.createElement('video'),728bool = false;729730// IE9 Running on Windows Server SKU can cause an exception to be thrown, bug #224731try {732if ( bool = !!elem.canPlayType ) {733bool = new Boolean(bool);734bool.ogg = elem.canPlayType('video/ogg; codecs="theora"') .replace(/^no$/,'');735736// Without QuickTime, this value will be `undefined`. github.com/Modernizr/Modernizr/issues/546737bool.h264 = elem.canPlayType('video/mp4; codecs="avc1.42E01E"') .replace(/^no$/,'');738739bool.webm = elem.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,'');740}741742} catch(e) { }743744return bool;745};746747tests['audio'] = function() {748var elem = document.createElement('audio'),749bool = false;750751try {752if ( bool = !!elem.canPlayType ) {753bool = new Boolean(bool);754bool.ogg = elem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,'');755bool.mp3 = elem.canPlayType('audio/mpeg;') .replace(/^no$/,'');756757// Mimetypes accepted:758// developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements759// bit.ly/iphoneoscodecs760bool.wav = elem.canPlayType('audio/wav; codecs="1"') .replace(/^no$/,'');761bool.m4a = ( elem.canPlayType('audio/x-m4a;') ||762elem.canPlayType('audio/aac;')) .replace(/^no$/,'');763}764} catch(e) { }765766return bool;767};768769770// In FF4, if disabled, window.localStorage should === null.771772// Normally, we could not test that directly and need to do a773// `('localStorage' in window) && ` test first because otherwise Firefox will774// throw bugzil.la/365772 if cookies are disabled775776// Also in iOS5 Private Browsing mode, attempting to use localStorage.setItem777// will throw the exception:778// QUOTA_EXCEEDED_ERRROR DOM Exception 22.779// Peculiarly, getItem and removeItem calls do not throw.780781// Because we are forced to try/catch this, we'll go aggressive.782783// Just FWIW: IE8 Compat mode supports these features completely:784// www.quirksmode.org/dom/html5.html785// But IE8 doesn't support either with local files786787tests['localstorage'] = function() {788try {789localStorage.setItem(mod, mod);790localStorage.removeItem(mod);791return true;792} catch(e) {793return false;794}795};796797tests['sessionstorage'] = function() {798try {799sessionStorage.setItem(mod, mod);800sessionStorage.removeItem(mod);801return true;802} catch(e) {803return false;804}805};806807808tests['webworkers'] = function() {809return !!window.Worker;810};811812813tests['applicationcache'] = function() {814return !!window.applicationCache;815};816817818// Thanks to Erik Dahlstrom819tests['svg'] = function() {820return !!document.createElementNS && !!document.createElementNS(ns.svg, 'svg').createSVGRect;821};822823// specifically for SVG inline in HTML, not within XHTML824// test page: paulirish.com/demo/inline-svg825tests['inlinesvg'] = function() {826var div = document.createElement('div');827div.innerHTML = '<svg/>';828return (div.firstChild && div.firstChild.namespaceURI) == ns.svg;829};830831// SVG SMIL animation832tests['smil'] = function() {833return !!document.createElementNS && /SVGAnimate/.test(toString.call(document.createElementNS(ns.svg, 'animate')));834};835836// This test is only for clip paths in SVG proper, not clip paths on HTML content837// demo: srufaculty.sru.edu/david.dailey/svg/newstuff/clipPath4.svg838839// However read the comments to dig into applying SVG clippaths to HTML content here:840// github.com/Modernizr/Modernizr/issues/213#issuecomment-1149491841tests['svgclippaths'] = function() {842return !!document.createElementNS && /SVGClipPath/.test(toString.call(document.createElementNS(ns.svg, 'clipPath')));843};844845/*>>webforms*/846// input features and input types go directly onto the ret object, bypassing the tests loop.847// Hold this guy to execute in a moment.848function webforms() {849/*>>input*/850// Run through HTML5's new input attributes to see if the UA understands any.851// We're using f which is the <input> element created early on852// Mike Taylr has created a comprehensive resource for testing these attributes853// when applied to all input types:854// miketaylr.com/code/input-type-attr.html855// spec: www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary856857// Only input placeholder is tested while textarea's placeholder is not.858// Currently Safari 4 and Opera 11 have support only for the input placeholder859// Both tests are available in feature-detects/forms-placeholder.js860Modernizr['input'] = (function( props ) {861for ( var i = 0, len = props.length; i < len; i++ ) {862attrs[ props[i] ] = !!(props[i] in inputElem);863}864if (attrs.list){865// safari false positive's on datalist: webk.it/74252866// see also github.com/Modernizr/Modernizr/issues/146867attrs.list = !!(document.createElement('datalist') && window.HTMLDataListElement);868}869return attrs;870})('autocomplete autofocus list placeholder max min multiple pattern required step'.split(' '));871/*>>input*/872873/*>>inputtypes*/874// Run through HTML5's new input types to see if the UA understands any.875// This is put behind the tests runloop because it doesn't return a876// true/false like all the other tests; instead, it returns an object877// containing each input type with its corresponding true/false value878879// Big thanks to @miketaylr for the html5 forms expertise. miketaylr.com/880Modernizr['inputtypes'] = (function(props) {881882for ( var i = 0, bool, inputElemType, defaultView, len = props.length; i < len; i++ ) {883884inputElem.setAttribute('type', inputElemType = props[i]);885bool = inputElem.type !== 'text';886887// We first check to see if the type we give it sticks..888// If the type does, we feed it a textual value, which shouldn't be valid.889// If the value doesn't stick, we know there's input sanitization which infers a custom UI890if ( bool ) {891892inputElem.value = smile;893inputElem.style.cssText = 'position:absolute;visibility:hidden;';894895if ( /^range$/.test(inputElemType) && inputElem.style.WebkitAppearance !== undefined ) {896897docElement.appendChild(inputElem);898defaultView = document.defaultView;899900// Safari 2-4 allows the smiley as a value, despite making a slider901bool = defaultView.getComputedStyle &&902defaultView.getComputedStyle(inputElem, null).WebkitAppearance !== 'textfield' &&903// Mobile android web browser has false positive, so must904// check the height to see if the widget is actually there.905(inputElem.offsetHeight !== 0);906907docElement.removeChild(inputElem);908909} else if ( /^(search|tel)$/.test(inputElemType) ){910// Spec doesn't define any special parsing or detectable UI911// behaviors so we pass these through as true912913// Interestingly, opera fails the earlier test, so it doesn't914// even make it here.915916} else if ( /^(url|email)$/.test(inputElemType) ) {917// Real url and email support comes with prebaked validation.918bool = inputElem.checkValidity && inputElem.checkValidity() === false;919920} else {921// If the upgraded input compontent rejects the :) text, we got a winner922bool = inputElem.value != smile;923}924}925926inputs[ props[i] ] = !!bool;927}928return inputs;929})('search tel url email datetime date month week time datetime-local number range color'.split(' '));930/*>>inputtypes*/931}932/*>>webforms*/933934935// End of test definitions936// -----------------------937938939940// Run through all tests and detect their support in the current UA.941// todo: hypothetically we could be doing an array of tests and use a basic loop here.942for ( var feature in tests ) {943if ( hasOwnProp(tests, feature) ) {944// run the test, throw the return value into the Modernizr,945// then based on that boolean, define an appropriate className946// and push it into an array of classes we'll join later.947featureName = feature.toLowerCase();948Modernizr[featureName] = tests[feature]();949950classes.push((Modernizr[featureName] ? '' : 'no-') + featureName);951}952}953954/*>>webforms*/955// input tests need to run.956Modernizr.input || webforms();957/*>>webforms*/958959960/**961* addTest allows the user to define their own feature tests962* the result will be added onto the Modernizr object,963* as well as an appropriate className set on the html element964*965* @param feature - String naming the feature966* @param test - Function returning true if feature is supported, false if not967*/968Modernizr.addTest = function ( feature, test ) {969if ( typeof feature == 'object' ) {970for ( var key in feature ) {971if ( hasOwnProp( feature, key ) ) {972Modernizr.addTest( key, feature[ key ] );973}974}975} else {976977feature = feature.toLowerCase();978979if ( Modernizr[feature] !== undefined ) {980// we're going to quit if you're trying to overwrite an existing test981// if we were to allow it, we'd do this:982// var re = new RegExp("\\b(no-)?" + feature + "\\b");983// docElement.className = docElement.className.replace( re, '' );984// but, no rly, stuff 'em.985return Modernizr;986}987988test = typeof test == 'function' ? test() : test;989990if (typeof enableClasses !== "undefined" && enableClasses) {991docElement.className += ' ' + (test ? '' : 'no-') + feature;992}993Modernizr[feature] = test;994995}996997return Modernizr; // allow chaining.998};99910001001// Reset modElem.cssText to nothing to reduce memory footprint.1002setCss('');1003modElem = inputElem = null;10041005/*>>shiv*/1006/**1007* @preserve HTML5 Shiv prev3.7.1 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed1008*/1009;(function(window, document) {1010/*jshint evil:true */1011/** version */1012var version = '3.7.0';10131014/** Preset options */1015var options = window.html5 || {};10161017/** Used to skip problem elements */1018var reSkip = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i;10191020/** Not all elements can be cloned in IE **/1021var saveClones = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i;10221023/** Detect whether the browser supports default html5 styles */1024var supportsHtml5Styles;10251026/** Name of the expando, to work with multiple documents or to re-shiv one document */1027var expando = '_html5shiv';10281029/** The id for the the documents expando */1030var expanID = 0;10311032/** Cached data for each document */1033var expandoData = {};10341035/** Detect whether the browser supports unknown elements */1036var supportsUnknownElements;10371038(function() {1039try {1040var a = document.createElement('a');1041a.innerHTML = '<xyz></xyz>';1042//if the hidden property is implemented we can assume, that the browser supports basic HTML5 Styles1043supportsHtml5Styles = ('hidden' in a);10441045supportsUnknownElements = a.childNodes.length == 1 || (function() {1046// assign a false positive if unable to shiv1047(document.createElement)('a');1048var frag = document.createDocumentFragment();1049return (1050typeof frag.cloneNode == 'undefined' ||1051typeof frag.createDocumentFragment == 'undefined' ||1052typeof frag.createElement == 'undefined'1053);1054}());1055} catch(e) {1056// assign a false positive if detection fails => unable to shiv1057supportsHtml5Styles = true;1058supportsUnknownElements = true;1059}10601061}());10621063/*--------------------------------------------------------------------------*/10641065/**1066* Creates a style sheet with the given CSS text and adds it to the document.1067* @private1068* @param {Document} ownerDocument The document.1069* @param {String} cssText The CSS text.1070* @returns {StyleSheet} The style element.1071*/1072function addStyleSheet(ownerDocument, cssText) {1073var p = ownerDocument.createElement('p'),1074parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement;10751076p.innerHTML = 'x<style>' + cssText + '</style>';1077return parent.insertBefore(p.lastChild, parent.firstChild);1078}10791080/**1081* Returns the value of `html5.elements` as an array.1082* @private1083* @returns {Array} An array of shived element node names.1084*/1085function getElements() {1086var elements = html5.elements;1087return typeof elements == 'string' ? elements.split(' ') : elements;1088}10891090/**1091* Returns the data associated to the given document1092* @private1093* @param {Document} ownerDocument The document.1094* @returns {Object} An object of data.1095*/1096function getExpandoData(ownerDocument) {1097var data = expandoData[ownerDocument[expando]];1098if (!data) {1099data = {};1100expanID++;1101ownerDocument[expando] = expanID;1102expandoData[expanID] = data;1103}1104return data;1105}11061107/**1108* returns a shived element for the given nodeName and document1109* @memberOf html51110* @param {String} nodeName name of the element1111* @param {Document} ownerDocument The context document.1112* @returns {Object} The shived element.1113*/1114function createElement(nodeName, ownerDocument, data){1115if (!ownerDocument) {1116ownerDocument = document;1117}1118if(supportsUnknownElements){1119return ownerDocument.createElement(nodeName);1120}1121if (!data) {1122data = getExpandoData(ownerDocument);1123}1124var node;11251126if (data.cache[nodeName]) {1127node = data.cache[nodeName].cloneNode();1128} else if (saveClones.test(nodeName)) {1129node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode();1130} else {1131node = data.createElem(nodeName);1132}11331134// Avoid adding some elements to fragments in IE < 9 because1135// * Attributes like `name` or `type` cannot be set/changed once an element1136// is inserted into a document/fragment1137// * Link elements with `src` attributes that are inaccessible, as with1138// a 403 response, will cause the tab/window to crash1139// * Script elements appended to fragments will execute when their `src`1140// or `text` property is set1141return node.canHaveChildren && !reSkip.test(nodeName) && !node.tagUrn ? data.frag.appendChild(node) : node;1142}11431144/**1145* returns a shived DocumentFragment for the given document1146* @memberOf html51147* @param {Document} ownerDocument The context document.1148* @returns {Object} The shived DocumentFragment.1149*/1150function createDocumentFragment(ownerDocument, data){1151if (!ownerDocument) {1152ownerDocument = document;1153}1154if(supportsUnknownElements){1155return ownerDocument.createDocumentFragment();1156}1157data = data || getExpandoData(ownerDocument);1158var clone = data.frag.cloneNode(),1159i = 0,1160elems = getElements(),1161l = elems.length;1162for(;i<l;i++){1163clone.createElement(elems[i]);1164}1165return clone;1166}11671168/**1169* Shivs the `createElement` and `createDocumentFragment` methods of the document.1170* @private1171* @param {Document|DocumentFragment} ownerDocument The document.1172* @param {Object} data of the document.1173*/1174function shivMethods(ownerDocument, data) {1175if (!data.cache) {1176data.cache = {};1177data.createElem = ownerDocument.createElement;1178data.createFrag = ownerDocument.createDocumentFragment;1179data.frag = data.createFrag();1180}118111821183ownerDocument.createElement = function(nodeName) {1184//abort shiv1185if (!html5.shivMethods) {1186return data.createElem(nodeName);1187}1188return createElement(nodeName, ownerDocument, data);1189};11901191ownerDocument.createDocumentFragment = Function('h,f', 'return function(){' +1192'var n=f.cloneNode(),c=n.createElement;' +1193'h.shivMethods&&(' +1194// unroll the `createElement` calls1195getElements().join().replace(/[\w\-]+/g, function(nodeName) {1196data.createElem(nodeName);1197data.frag.createElement(nodeName);1198return 'c("' + nodeName + '")';1199}) +1200');return n}'1201)(html5, data.frag);1202}12031204/*--------------------------------------------------------------------------*/12051206/**1207* Shivs the given document.1208* @memberOf html51209* @param {Document} ownerDocument The document to shiv.1210* @returns {Document} The shived document.1211*/1212function shivDocument(ownerDocument) {1213if (!ownerDocument) {1214ownerDocument = document;1215}1216var data = getExpandoData(ownerDocument);12171218if (html5.shivCSS && !supportsHtml5Styles && !data.hasCSS) {1219data.hasCSS = !!addStyleSheet(ownerDocument,1220// corrects block display not defined in IE6/7/8/91221'article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}' +1222// adds styling not present in IE6/7/8/91223'mark{background:#FF0;color:#000}' +1224// hides non-rendered elements1225'template{display:none}'1226);1227}1228if (!supportsUnknownElements) {1229shivMethods(ownerDocument, data);1230}1231return ownerDocument;1232}12331234/*--------------------------------------------------------------------------*/12351236/**1237* The `html5` object is exposed so that more elements can be shived and1238* existing shiving can be detected on iframes.1239* @type Object1240* @example1241*1242* // options can be changed before the script is included1243* html5 = { 'elements': 'mark section', 'shivCSS': false, 'shivMethods': false };1244*/1245var html5 = {12461247/**1248* An array or space separated string of node names of the elements to shiv.1249* @memberOf html51250* @type Array|String1251*/1252'elements': options.elements || 'abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video',12531254/**1255* current version of html5shiv1256*/1257'version': version,12581259/**1260* A flag to indicate that the HTML5 style sheet should be inserted.1261* @memberOf html51262* @type Boolean1263*/1264'shivCSS': (options.shivCSS !== false),12651266/**1267* Is equal to true if a browser supports creating unknown/HTML5 elements1268* @memberOf html51269* @type boolean1270*/1271'supportsUnknownElements': supportsUnknownElements,12721273/**1274* A flag to indicate that the document's `createElement` and `createDocumentFragment`1275* methods should be overwritten.1276* @memberOf html51277* @type Boolean1278*/1279'shivMethods': (options.shivMethods !== false),12801281/**1282* A string to describe the type of `html5` object ("default" or "default print").1283* @memberOf html51284* @type String1285*/1286'type': 'default',12871288// shivs the document according to the specified `html5` object options1289'shivDocument': shivDocument,12901291//creates a shived element1292createElement: createElement,12931294//creates a shived documentFragment1295createDocumentFragment: createDocumentFragment1296};12971298/*--------------------------------------------------------------------------*/12991300// expose html51301window.html5 = html5;13021303// shiv the document1304shivDocument(document);13051306}(this, document));1307/*>>shiv*/13081309// Assign private properties to the return object with prefix1310Modernizr._version = version;13111312// expose these for the plugin API. Look in the source for how to join() them against your input1313/*>>prefixes*/1314Modernizr._prefixes = prefixes;1315/*>>prefixes*/1316/*>>domprefixes*/1317Modernizr._domPrefixes = domPrefixes;1318Modernizr._cssomPrefixes = cssomPrefixes;1319/*>>domprefixes*/13201321/*>>mq*/1322// Modernizr.mq tests a given media query, live against the current state of the window1323// A few important notes:1324// * If a browser does not support media queries at all (eg. oldIE) the mq() will always return false1325// * A max-width or orientation query will be evaluated against the current state, which may change later.1326// * You must specify values. Eg. If you are testing support for the min-width media query use:1327// Modernizr.mq('(min-width:0)')1328// usage:1329// Modernizr.mq('only screen and (max-width:768)')1330Modernizr.mq = testMediaQuery;1331/*>>mq*/13321333/*>>hasevent*/1334// Modernizr.hasEvent() detects support for a given event, with an optional element to test on1335// Modernizr.hasEvent('gesturestart', elem)1336Modernizr.hasEvent = isEventSupported;1337/*>>hasevent*/13381339/*>>testprop*/1340// Modernizr.testProp() investigates whether a given style property is recognized1341// Note that the property names must be provided in the camelCase variant.1342// Modernizr.testProp('pointerEvents')1343Modernizr.testProp = function(prop){1344return testProps([prop]);1345};1346/*>>testprop*/13471348/*>>testallprops*/1349// Modernizr.testAllProps() investigates whether a given style property,1350// or any of its vendor-prefixed variants, is recognized1351// Note that the property names must be provided in the camelCase variant.1352// Modernizr.testAllProps('boxSizing')1353Modernizr.testAllProps = testPropsAll;1354/*>>testallprops*/135513561357/*>>teststyles*/1358// Modernizr.testStyles() allows you to add custom styles to the document and test an element afterwards1359// Modernizr.testStyles('#modernizr { position:absolute }', function(elem, rule){ ... })1360Modernizr.testStyles = injectElementWithStyles;1361/*>>teststyles*/136213631364/*>>prefixed*/1365// Modernizr.prefixed() returns the prefixed or nonprefixed property name variant of your input1366// Modernizr.prefixed('boxSizing') // 'MozBoxSizing'13671368// Properties must be passed as dom-style camelcase, rather than `box-sizing` hypentated style.1369// Return values will also be the camelCase variant, if you need to translate that to hypenated style use:1370//1371// str.replace(/([A-Z])/g, function(str,m1){ return '-' + m1.toLowerCase(); }).replace(/^ms-/,'-ms-');13721373// If you're trying to ascertain which transition end event to bind to, you might do something like...1374//1375// var transEndEventNames = {1376// 'WebkitTransition' : 'webkitTransitionEnd',1377// 'MozTransition' : 'transitionend',1378// 'OTransition' : 'oTransitionEnd',1379// 'msTransition' : 'MSTransitionEnd',1380// 'transition' : 'transitionend'1381// },1382// transEndEventName = transEndEventNames[ Modernizr.prefixed('transition') ];13831384Modernizr.prefixed = function(prop, obj, elem){1385if(!obj) {1386return testPropsAll(prop, 'pfx');1387} else {1388// Testing DOM property e.g. Modernizr.prefixed('requestAnimationFrame', window) // 'mozRequestAnimationFrame'1389return testPropsAll(prop, obj, elem);1390}1391};1392/*>>prefixed*/139313941395/*>>cssclasses*/1396// Remove "no-js" class from <html> element, if it exists:1397docElement.className = docElement.className.replace(/(^|\s)no-js(\s|$)/, '$1$2') +13981399// Add the new classes to the <html> element.1400(enableClasses ? ' js ' + classes.join(' ') : '');1401/*>>cssclasses*/14021403return Modernizr;14041405})(this, this.document);140614071408