modernizr.js 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296
  1. /*!
  2. * Modernizr v2.6pre
  3. * www.modernizr.com
  4. *
  5. * Copyright (c) Faruk Ates, Paul Irish, Alex Sexton
  6. * Available under the BSD and MIT licenses: www.modernizr.com/license/
  7. */
  8. /*
  9. * Modernizr tests which native CSS3 and HTML5 features are available in
  10. * 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 the
  12. * <html> element. This information allows you to progressively enhance
  13. * your pages with a granular level of control over the experience.
  14. *
  15. * Modernizr has an optional (not included) conditional resource loader
  16. * called Modernizr.load(), based on Yepnope.js (yepnopejs.com).
  17. * To get a build that includes Modernizr.load(), as well as choosing
  18. * which tests to include, go to www.modernizr.com/download/
  19. *
  20. * Authors Faruk Ates, Paul Irish, Alex Sexton
  21. * Contributors Ryan Seddon, Ben Alman
  22. */
  23. window.Modernizr = (function( window, document, undefined ) {
  24. var version = '2.5.3',
  25. Modernizr = {},
  26. /*>>cssclasses*/
  27. // option for enabling the HTML classes to be added
  28. enableClasses = true,
  29. /*>>cssclasses*/
  30. docElement = document.documentElement,
  31. /**
  32. * Create our "modernizr" element that we do most feature tests on.
  33. */
  34. mod = 'modernizr',
  35. modElem = document.createElement(mod),
  36. mStyle = modElem.style,
  37. /**
  38. * Create the input element for various Web Forms feature tests.
  39. */
  40. inputElem /*>>inputelem*/ = document.createElement('input') /*>>inputelem*/ ,
  41. /*>>smile*/
  42. smile = ':)',
  43. /*>>smile*/
  44. toString = {}.toString,
  45. // TODO :: make the prefixes more granular
  46. /*>>prefixes*/
  47. // List of property values to set for css tests. See ticket #21
  48. prefixes = ' -webkit- -moz- -o- -ms- '.split(' '),
  49. /*>>prefixes*/
  50. /*>>domprefixes*/
  51. // Following spec is to expose vendor-specific style properties as:
  52. // elem.style.WebkitBorderRadius
  53. // and the following would be incorrect:
  54. // elem.style.webkitBorderRadius
  55. // Webkit ghosts their properties in lowercase but Opera & Moz do not.
  56. // Microsoft uses a lowercase `ms` instead of the correct `Ms` in IE8+
  57. // erik.eae.net/archives/2008/03/10/21.48.10/
  58. // More here: github.com/Modernizr/Modernizr/issues/issue/21
  59. omPrefixes = 'Webkit Moz O ms',
  60. cssomPrefixes = omPrefixes.split(' '),
  61. domPrefixes = omPrefixes.toLowerCase().split(' '),
  62. /*>>domprefixes*/
  63. /*>>ns*/
  64. ns = {'svg': 'http://www.w3.org/2000/svg'},
  65. /*>>ns*/
  66. tests = {},
  67. inputs = {},
  68. attrs = {},
  69. classes = [],
  70. slice = classes.slice,
  71. featureName, // used in testing loop
  72. /*>>teststyles*/
  73. // Inject element with style element and some CSS rules
  74. injectElementWithStyles = function( rule, callback, nodes, testnames ) {
  75. var style, ret, node,
  76. div = document.createElement('div'),
  77. // After page load injecting a fake body doesn't work so check if body exists
  78. body = document.body,
  79. // IE6 and 7 won't return offsetWidth or offsetHeight unless it's in the body element, so we fake it.
  80. fakeBody = body ? body : document.createElement('body');
  81. if ( parseInt(nodes, 10) ) {
  82. // In order not to give false positives we create a node for each test
  83. // This also allows the method to scale for unspecified uses
  84. while ( nodes-- ) {
  85. node = document.createElement('div');
  86. node.id = testnames ? testnames[nodes] : mod + (nodes + 1);
  87. div.appendChild(node);
  88. }
  89. }
  90. // <style> elements in IE6-9 are considered 'NoScope' elements and therefore will be removed
  91. // when injected with innerHTML. To get around this you need to prepend the 'NoScope' element
  92. // with a 'scoped' element, in our case the soft-hyphen entity as it won't mess with our measurements.
  93. // msdn.microsoft.com/en-us/library/ms533897%28VS.85%29.aspx
  94. // Documents served as xml will throw if using &shy; so use xml friendly encoded version. See issue #277
  95. style = ['&#173;','<style id="s', mod, '">', rule, '</style>'].join('');
  96. div.id = mod;
  97. // 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.
  98. // Opera will act all quirky when injecting elements in documentElement when page is served as xml, needs fakebody too. #270
  99. (body ? div : fakeBody).innerHTML += style;
  100. fakeBody.appendChild(div);
  101. if ( !body ) {
  102. //avoid crashing IE8, if background image is used
  103. fakeBody.style.background = "";
  104. docElement.appendChild(fakeBody);
  105. }
  106. ret = callback(div, rule);
  107. // If this is done after page load we don't want to remove the body so check if body exists
  108. !body ? fakeBody.parentNode.removeChild(fakeBody) : div.parentNode.removeChild(div);
  109. return !!ret;
  110. },
  111. /*>>teststyles*/
  112. /*>>mq*/
  113. // adapted from matchMedia polyfill
  114. // by Scott Jehl and Paul Irish
  115. // gist.github.com/786768
  116. testMediaQuery = function( mq ) {
  117. var matchMedia = window.matchMedia || window.msMatchMedia;
  118. if ( matchMedia ) {
  119. return matchMedia(mq).matches;
  120. }
  121. var bool;
  122. injectElementWithStyles('@media ' + mq + ' { #' + mod + ' { position: absolute; } }', function( node ) {
  123. bool = (window.getComputedStyle ?
  124. getComputedStyle(node, null) :
  125. node.currentStyle)['position'] == 'absolute';
  126. });
  127. return bool;
  128. },
  129. /*>>mq*/
  130. /*>>hasevent*/
  131. //
  132. // isEventSupported determines if a given element supports the given event
  133. // kangax.github.com/iseventsupported/
  134. //
  135. // The following results are known incorrects:
  136. // Modernizr.hasEvent("webkitTransitionEnd", elem) // false negative
  137. // Modernizr.hasEvent("textInput") // in Webkit. github.com/Modernizr/Modernizr/issues/333
  138. // ...
  139. isEventSupported = (function() {
  140. var TAGNAMES = {
  141. 'select': 'input', 'change': 'input',
  142. 'submit': 'form', 'reset': 'form',
  143. 'error': 'img', 'load': 'img', 'abort': 'img'
  144. };
  145. function isEventSupported( eventName, element ) {
  146. element = element || document.createElement(TAGNAMES[eventName] || 'div');
  147. eventName = 'on' + eventName;
  148. // When using `setAttribute`, IE skips "unload", WebKit skips "unload" and "resize", whereas `in` "catches" those
  149. var isSupported = eventName in element;
  150. if ( !isSupported ) {
  151. // If it has no `setAttribute` (i.e. doesn't implement Node interface), try generic element
  152. if ( !element.setAttribute ) {
  153. element = document.createElement('div');
  154. }
  155. if ( element.setAttribute && element.removeAttribute ) {
  156. element.setAttribute(eventName, '');
  157. isSupported = is(element[eventName], 'function');
  158. // If property was created, "remove it" (by setting value to `undefined`)
  159. if ( !is(element[eventName], 'undefined') ) {
  160. element[eventName] = undefined;
  161. }
  162. element.removeAttribute(eventName);
  163. }
  164. }
  165. element = null;
  166. return isSupported;
  167. }
  168. return isEventSupported;
  169. })(),
  170. /*>>hasevent*/
  171. // TODO :: Add flag for hasownprop ? didn't last time
  172. // hasOwnProperty shim by kangax needed for Safari 2.0 support
  173. _hasOwnProperty = ({}).hasOwnProperty, hasOwnProperty;
  174. if ( !is(_hasOwnProperty, 'undefined') && !is(_hasOwnProperty.call, 'undefined') ) {
  175. hasOwnProperty = function (object, property) {
  176. return _hasOwnProperty.call(object, property);
  177. };
  178. }
  179. else {
  180. hasOwnProperty = function (object, property) { /* yes, this can give false positives/negatives, but most of the time we don't care about those */
  181. return ((property in object) && is(object.constructor.prototype[property], 'undefined'));
  182. };
  183. }
  184. // Adapted from ES5-shim https://github.com/kriskowal/es5-shim/blob/master/es5-shim.js
  185. // es5.github.com/#x15.3.4.5
  186. if (!Function.prototype.bind) {
  187. Function.prototype.bind = function bind(that) {
  188. var target = this;
  189. if (typeof target != "function") throw new TypeError();
  190. var
  191. args = slice.call(arguments, 1),
  192. bound = function () {
  193. if (this instanceof bound) {
  194. var F = function(){};
  195. F.prototype = target.prototype;
  196. var self = new F();
  197. var result = target.apply(self, args.concat(slice.call(arguments)));
  198. if (Object(result) === result) return result;
  199. return self;
  200. } else {
  201. return target.apply( that, args.concat(slice.call(arguments)));
  202. }
  203. };
  204. return bound;
  205. };
  206. }
  207. /**
  208. * setCss applies given styles to the Modernizr DOM node.
  209. */
  210. function setCss( str ) {
  211. mStyle.cssText = str;
  212. }
  213. /**
  214. * setCssAll extrapolates all vendor-specific css strings.
  215. */
  216. function setCssAll( str1, str2 ) {
  217. return setCss(prefixes.join(str1 + ';') + ( str2 || '' ));
  218. }
  219. /**
  220. * is returns a boolean for if typeof obj is exactly type.
  221. */
  222. function is( obj, type ) {
  223. return typeof obj === type;
  224. }
  225. /**
  226. * contains returns a boolean for if substr is found within str.
  227. */
  228. function contains( str, substr ) {
  229. return !!~('' + str).indexOf(substr);
  230. }
  231. /*>>testprop*/
  232. // testProps is a generic CSS / DOM property test.
  233. // In testing support for a given CSS property, it's legit to test:
  234. // `elem.style[styleName] !== undefined`
  235. // If the property is supported it will return an empty string,
  236. // if unsupported it will return undefined.
  237. // We'll take advantage of this quick test and skip setting a style
  238. // on our modernizr element, but instead just testing undefined vs
  239. // empty string.
  240. function testProps( props, prefixed ) {
  241. for ( var i in props ) {
  242. if ( mStyle[ props[i] ] !== undefined ) {
  243. return prefixed == 'pfx' ? props[i] : true;
  244. }
  245. }
  246. return false;
  247. }
  248. /*>>testprop*/
  249. // TODO :: add testDOMProps
  250. /**
  251. * testDOMProps is a generic DOM property test; if a browser supports
  252. * a certain property, it won't return undefined for it.
  253. */
  254. function testDOMProps( props, obj, elem ) {
  255. for ( var i in props ) {
  256. var item = obj[props[i]];
  257. if ( item !== undefined) {
  258. // return the property name as a string
  259. if (elem === false) return props[i];
  260. // let's bind a function
  261. if (is(item, 'function')){
  262. // default to autobind unless override
  263. return item.bind(elem || obj);
  264. }
  265. // return the unbound function or obj or value
  266. return item;
  267. }
  268. }
  269. return false;
  270. }
  271. /*>>testallprops*/
  272. /**
  273. * testPropsAll tests a list of DOM properties we want to check against.
  274. * We specify literally ALL possible (known and/or likely) properties on
  275. * the element including the non-vendor prefixed one, for forward-
  276. * compatibility.
  277. */
  278. function testPropsAll( prop, prefixed, elem ) {
  279. var ucProp = prop.charAt(0).toUpperCase() + prop.substr(1),
  280. props = (prop + ' ' + cssomPrefixes.join(ucProp + ' ') + ucProp).split(' ');
  281. // did they call .prefixed('boxSizing') or are we just testing a prop?
  282. if(is(prefixed, "string") || is(prefixed, "undefined")) {
  283. return testProps(props, prefixed);
  284. // otherwise, they called .prefixed('requestAnimationFrame', window[, elem])
  285. } else {
  286. props = (prop + ' ' + (domPrefixes).join(ucProp + ' ') + ucProp).split(' ');
  287. return testDOMProps(props, prefixed, elem);
  288. }
  289. }
  290. /*>>testallprops*/
  291. /**
  292. * Tests
  293. * -----
  294. */
  295. // The *new* flexbox
  296. // dev.w3.org/csswg/css3-flexbox
  297. tests['flexbox'] = function() {
  298. return testPropsAll('flexWrap');
  299. };
  300. // The *old* flexbox
  301. // www.w3.org/TR/2009/WD-css3-flexbox-20090723/
  302. tests['flexboxlegacy'] = function() {
  303. return testPropsAll('boxDirection');
  304. };
  305. // On the S60 and BB Storm, getContext exists, but always returns undefined
  306. // so we actually have to call getContext() to verify
  307. // github.com/Modernizr/Modernizr/issues/issue/97/
  308. tests['canvas'] = function() {
  309. var elem = document.createElement('canvas');
  310. return !!(elem.getContext && elem.getContext('2d'));
  311. };
  312. tests['canvastext'] = function() {
  313. return !!(Modernizr['canvas'] && is(document.createElement('canvas').getContext('2d').fillText, 'function'));
  314. };
  315. // webk.it/70117 is tracking a legit WebGL feature detect proposal
  316. // We do a soft detect which may false positive in order to avoid
  317. // an expensive context creation: bugzil.la/732441
  318. tests['webgl'] = function() {
  319. return !!window.WebGLRenderingContext;
  320. };
  321. /*
  322. * The Modernizr.touch test only indicates if the browser supports
  323. * touch events, which does not necessarily reflect a touchscreen
  324. * device, as evidenced by tablets running Windows 7 or, alas,
  325. * the Palm Pre / WebOS (touch) phones.
  326. *
  327. * Additionally, Chrome (desktop) used to lie about its support on this,
  328. * but that has since been rectified: crbug.com/36415
  329. *
  330. * We also test for Firefox 4 Multitouch Support.
  331. *
  332. * For more info, see: modernizr.github.com/Modernizr/touch.html
  333. */
  334. tests['touch'] = function() {
  335. var bool;
  336. if(('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) {
  337. bool = true;
  338. } else {
  339. injectElementWithStyles(['@media (',prefixes.join('touch-enabled),('),mod,')','{#modernizr{top:9px;position:absolute}}'].join(''), function( node ) {
  340. bool = node.offsetTop === 9;
  341. });
  342. }
  343. return bool;
  344. };
  345. // geolocation is often considered a trivial feature detect...
  346. // Turns out, it's quite tricky to get right:
  347. //
  348. // Using !!navigator.geolocation does two things we don't want. It:
  349. // 1. Leaks memory in IE9: github.com/Modernizr/Modernizr/issues/513
  350. // 2. Disables page caching in WebKit: webk.it/43956
  351. //
  352. // Meanwhile, in Firefox < 8, an about:config setting could expose
  353. // a false positive that would throw an exception: bugzil.la/688158
  354. tests['geolocation'] = function() {
  355. return 'geolocation' in navigator;
  356. };
  357. tests['postmessage'] = function() {
  358. return !!window.postMessage;
  359. };
  360. // Chrome incognito mode used to throw an exception when using openDatabase
  361. // It doesn't anymore.
  362. tests['websqldatabase'] = function() {
  363. return !!window.openDatabase;
  364. };
  365. // Vendors had inconsistent prefixing with the experimental Indexed DB:
  366. // - Webkit's implementation is accessible through webkitIndexedDB
  367. // - Firefox shipped moz_indexedDB before FF4b9, but since then has been mozIndexedDB
  368. // For speed, we don't test the legacy (and beta-only) indexedDB
  369. tests['indexedDB'] = function() {
  370. return !!testPropsAll("indexedDB", window);
  371. };
  372. // documentMode logic from YUI to filter out IE8 Compat Mode
  373. // which false positives.
  374. tests['hashchange'] = function() {
  375. return isEventSupported('hashchange', window) && (document.documentMode === undefined || document.documentMode > 7);
  376. };
  377. // Per 1.6:
  378. // This used to be Modernizr.historymanagement but the longer
  379. // name has been deprecated in favor of a shorter and property-matching one.
  380. // The old API is still available in 1.6, but as of 2.0 will throw a warning,
  381. // and in the first release thereafter disappear entirely.
  382. tests['history'] = function() {
  383. return !!(window.history && history.pushState);
  384. };
  385. tests['draganddrop'] = function() {
  386. var div = document.createElement('div');
  387. return ('draggable' in div) || ('ondragstart' in div && 'ondrop' in div);
  388. };
  389. // FF3.6 was EOL'ed on 4/24/12, but the ESR version of FF10
  390. // will be supported until FF19 (2/12/13), at which time, ESR becomes FF17.
  391. // FF10 still uses prefixes, so check for it until then.
  392. // for more ESR info, see: mozilla.org/en-US/firefox/organizations/faq/
  393. tests['websockets'] = function() {
  394. return 'WebSocket' in window || 'MozWebSocket' in window;
  395. };
  396. // css-tricks.com/rgba-browser-support/
  397. tests['rgba'] = function() {
  398. // Set an rgba() color and check the returned value
  399. setCss('background-color:rgba(150,255,150,.5)');
  400. return contains(mStyle.backgroundColor, 'rgba');
  401. };
  402. tests['hsla'] = function() {
  403. // Same as rgba(), in fact, browsers re-map hsla() to rgba() internally,
  404. // except IE9 who retains it as hsla
  405. setCss('background-color:hsla(120,40%,100%,.5)');
  406. return contains(mStyle.backgroundColor, 'rgba') || contains(mStyle.backgroundColor, 'hsla');
  407. };
  408. tests['multiplebgs'] = function() {
  409. // Setting multiple images AND a color on the background shorthand property
  410. // and then querying the style.background property value for the number of
  411. // occurrences of "url(" is a reliable method for detecting ACTUAL support for this!
  412. setCss('background:url(https://),url(https://),red url(https://)');
  413. // If the UA supports multiple backgrounds, there should be three occurrences
  414. // of the string "url(" in the return value for elemStyle.background
  415. return /(url\s*\(.*?){3}/.test(mStyle.background);
  416. };
  417. // this will false positive in Opera Mini
  418. // github.com/Modernizr/Modernizr/issues/396
  419. tests['backgroundsize'] = function() {
  420. return testPropsAll('backgroundSize');
  421. };
  422. tests['borderimage'] = function() {
  423. return testPropsAll('borderImage');
  424. };
  425. // Super comprehensive table about all the unique implementations of
  426. // border-radius: muddledramblings.com/table-of-css3-border-radius-compliance
  427. tests['borderradius'] = function() {
  428. return testPropsAll('borderRadius');
  429. };
  430. // WebOS unfortunately false positives on this test.
  431. tests['boxshadow'] = function() {
  432. return testPropsAll('boxShadow');
  433. };
  434. // FF3.0 will false positive on this test
  435. tests['textshadow'] = function() {
  436. return document.createElement('div').style.textShadow === '';
  437. };
  438. tests['opacity'] = function() {
  439. // Browsers that actually have CSS Opacity implemented have done so
  440. // according to spec, which means their return values are within the
  441. // range of [0.0,1.0] - including the leading zero.
  442. setCssAll('opacity:.55');
  443. // The non-literal . in this regex is intentional:
  444. // German Chrome returns this value as 0,55
  445. // github.com/Modernizr/Modernizr/issues/#issue/59/comment/516632
  446. return /^0.55$/.test(mStyle.opacity);
  447. };
  448. // Note, Android < 4 will pass this test, but can only animate
  449. // a single property at a time
  450. // daneden.me/2011/12/putting-up-with-androids-bullshit/
  451. tests['cssanimations'] = function() {
  452. return testPropsAll('animationName');
  453. };
  454. tests['csscolumns'] = function() {
  455. return testPropsAll('columnCount');
  456. };
  457. tests['cssgradients'] = function() {
  458. /**
  459. * For CSS Gradients syntax, please see:
  460. * webkit.org/blog/175/introducing-css-gradients/
  461. * developer.mozilla.org/en/CSS/-moz-linear-gradient
  462. * developer.mozilla.org/en/CSS/-moz-radial-gradient
  463. * dev.w3.org/csswg/css3-images/#gradients-
  464. */
  465. var str1 = 'background-image:',
  466. str2 = 'gradient(linear,left top,right bottom,from(#9f9),to(white));',
  467. str3 = 'linear-gradient(left top,#9f9, white);';
  468. setCss(
  469. // legacy webkit syntax (FIXME: remove when syntax not in use anymore)
  470. (str1 + '-webkit- '.split(' ').join(str2 + str1)
  471. // standard syntax // trailing 'background-image:'
  472. + prefixes.join(str3 + str1)).slice(0, -str1.length)
  473. );
  474. return contains(mStyle.backgroundImage, 'gradient');
  475. };
  476. tests['cssreflections'] = function() {
  477. return testPropsAll('boxReflect');
  478. };
  479. tests['csstransforms'] = function() {
  480. return !!testPropsAll('transform');
  481. };
  482. tests['csstransforms3d'] = function() {
  483. var ret = !!testPropsAll('perspective');
  484. // Webkit's 3D transforms are passed off to the browser's own graphics renderer.
  485. // It works fine in Safari on Leopard and Snow Leopard, but not in Chrome in
  486. // some conditions. As a result, Webkit typically recognizes the syntax but
  487. // will sometimes throw a false positive, thus we must do a more thorough check:
  488. if ( ret && 'webkitPerspective' in docElement.style ) {
  489. // Webkit allows this media query to succeed only if the feature is enabled.
  490. // `@media (transform-3d),(-webkit-transform-3d){ ... }`
  491. injectElementWithStyles('@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}', function( node, rule ) {
  492. ret = node.offsetLeft === 9 && node.offsetHeight === 3;
  493. });
  494. }
  495. return ret;
  496. };
  497. tests['csstransitions'] = function() {
  498. return testPropsAll('transition');
  499. };
  500. /*>>fontface*/
  501. // @font-face detection routine by Diego Perini
  502. // javascript.nwbox.com/CSSSupport/
  503. // false positives:
  504. // WebOS github.com/Modernizr/Modernizr/issues/342
  505. // WP7 github.com/Modernizr/Modernizr/issues/538
  506. tests['fontface'] = function() {
  507. var bool;
  508. injectElementWithStyles('@font-face {font-family:"font";src:url("https://")}', function( node, rule ) {
  509. var style = document.getElementById('smodernizr'),
  510. sheet = style.sheet || style.styleSheet,
  511. cssText = sheet ? (sheet.cssRules && sheet.cssRules[0] ? sheet.cssRules[0].cssText : sheet.cssText || '') : '';
  512. bool = /src/i.test(cssText) && cssText.indexOf(rule.split(' ')[0]) === 0;
  513. });
  514. return bool;
  515. };
  516. /*>>fontface*/
  517. // CSS generated content detection
  518. tests['generatedcontent'] = function() {
  519. var bool;
  520. injectElementWithStyles(['#modernizr:after{content:"',smile,'";visibility:hidden}'].join(''), function( node ) {
  521. bool = node.offsetHeight >= 1;
  522. });
  523. return bool;
  524. };
  525. // These tests evaluate support of the video/audio elements, as well as
  526. // testing what types of content they support.
  527. //
  528. // We're using the Boolean constructor here, so that we can extend the value
  529. // e.g. Modernizr.video // true
  530. // Modernizr.video.ogg // 'probably'
  531. //
  532. // Codec values from : github.com/NielsLeenheer/html5test/blob/9106a8/index.html#L845
  533. // thx to NielsLeenheer and zcorpan
  534. // Note: in some older browsers, "no" was a return value instead of empty string.
  535. // It was live in FF3.5.0 and 3.5.1, but fixed in 3.5.2
  536. // It was also live in Safari 4.0.0 - 4.0.4, but fixed in 4.0.5
  537. tests['video'] = function() {
  538. var elem = document.createElement('video'),
  539. bool = false;
  540. // IE9 Running on Windows Server SKU can cause an exception to be thrown, bug #224
  541. try {
  542. if ( bool = !!elem.canPlayType ) {
  543. bool = new Boolean(bool);
  544. bool.ogg = elem.canPlayType('video/ogg; codecs="theora"') .replace(/^no$/,'');
  545. // Without QuickTime, this value will be `undefined`. github.com/Modernizr/Modernizr/issues/546
  546. bool.h264 = elem.canPlayType('video/mp4; codecs="avc1.42E01E"') .replace(/^no$/,'');
  547. bool.webm = elem.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,'');
  548. }
  549. } catch(e) { }
  550. return bool;
  551. };
  552. tests['audio'] = function() {
  553. var elem = document.createElement('audio'),
  554. bool = false;
  555. try {
  556. if ( bool = !!elem.canPlayType ) {
  557. bool = new Boolean(bool);
  558. bool.ogg = elem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,'');
  559. bool.mp3 = elem.canPlayType('audio/mpeg;') .replace(/^no$/,'');
  560. // Mimetypes accepted:
  561. // developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements
  562. // bit.ly/iphoneoscodecs
  563. bool.wav = elem.canPlayType('audio/wav; codecs="1"') .replace(/^no$/,'');
  564. bool.m4a = ( elem.canPlayType('audio/x-m4a;') ||
  565. elem.canPlayType('audio/aac;')) .replace(/^no$/,'');
  566. }
  567. } catch(e) { }
  568. return bool;
  569. };
  570. // In FF4, if disabled, window.localStorage should === null.
  571. // Normally, we could not test that directly and need to do a
  572. // `('localStorage' in window) && ` test first because otherwise Firefox will
  573. // throw bugzil.la/365772 if cookies are disabled
  574. // Also in iOS5 Private Browsing mode, attempting to use localStorage.setItem
  575. // will throw the exception:
  576. // QUOTA_EXCEEDED_ERRROR DOM Exception 22.
  577. // Peculiarly, getItem and removeItem calls do not throw.
  578. // Because we are forced to try/catch this, we'll go aggressive.
  579. // Just FWIW: IE8 Compat mode supports these features completely:
  580. // www.quirksmode.org/dom/html5.html
  581. // But IE8 doesn't support either with local files
  582. tests['localstorage'] = function() {
  583. try {
  584. localStorage.setItem(mod, mod);
  585. localStorage.removeItem(mod);
  586. return true;
  587. } catch(e) {
  588. return false;
  589. }
  590. };
  591. tests['sessionstorage'] = function() {
  592. try {
  593. sessionStorage.setItem(mod, mod);
  594. sessionStorage.removeItem(mod);
  595. return true;
  596. } catch(e) {
  597. return false;
  598. }
  599. };
  600. tests['webworkers'] = function() {
  601. return !!window.Worker;
  602. };
  603. tests['applicationcache'] = function() {
  604. return !!window.applicationCache;
  605. };
  606. // Thanks to Erik Dahlstrom
  607. tests['svg'] = function() {
  608. return !!document.createElementNS && !!document.createElementNS(ns.svg, 'svg').createSVGRect;
  609. };
  610. // specifically for SVG inline in HTML, not within XHTML
  611. // test page: paulirish.com/demo/inline-svg
  612. tests['inlinesvg'] = function() {
  613. var div = document.createElement('div');
  614. div.innerHTML = '<svg/>';
  615. return (div.firstChild && div.firstChild.namespaceURI) == ns.svg;
  616. };
  617. // SVG SMIL animation
  618. tests['smil'] = function() {
  619. return !!document.createElementNS && /SVGAnimate/.test(toString.call(document.createElementNS(ns.svg, 'animate')));
  620. };
  621. // This test is only for clip paths in SVG proper, not clip paths on HTML content
  622. // demo: srufaculty.sru.edu/david.dailey/svg/newstuff/clipPath4.svg
  623. // However read the comments to dig into applying SVG clippaths to HTML content here:
  624. // github.com/Modernizr/Modernizr/issues/213#issuecomment-1149491
  625. tests['svgclippaths'] = function() {
  626. return !!document.createElementNS && /SVGClipPath/.test(toString.call(document.createElementNS(ns.svg, 'clipPath')));
  627. };
  628. /*>>webforms*/
  629. // input features and input types go directly onto the ret object, bypassing the tests loop.
  630. // Hold this guy to execute in a moment.
  631. function webforms() {
  632. /*>>input*/
  633. // Run through HTML5's new input attributes to see if the UA understands any.
  634. // We're using f which is the <input> element created early on
  635. // Mike Taylr has created a comprehensive resource for testing these attributes
  636. // when applied to all input types:
  637. // miketaylr.com/code/input-type-attr.html
  638. // spec: www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
  639. // Only input placeholder is tested while textarea's placeholder is not.
  640. // Currently Safari 4 and Opera 11 have support only for the input placeholder
  641. // Both tests are available in feature-detects/forms-placeholder.js
  642. Modernizr['input'] = (function( props ) {
  643. for ( var i = 0, len = props.length; i < len; i++ ) {
  644. attrs[ props[i] ] = !!(props[i] in inputElem);
  645. }
  646. if (attrs.list){
  647. // safari false positive's on datalist: webk.it/74252
  648. // see also github.com/Modernizr/Modernizr/issues/146
  649. attrs.list = !!(document.createElement('datalist') && window.HTMLDataListElement);
  650. }
  651. return attrs;
  652. })('autocomplete autofocus list placeholder max min multiple pattern required step'.split(' '));
  653. /*>>input*/
  654. /*>>inputtypes*/
  655. // Run through HTML5's new input types to see if the UA understands any.
  656. // This is put behind the tests runloop because it doesn't return a
  657. // true/false like all the other tests; instead, it returns an object
  658. // containing each input type with its corresponding true/false value
  659. // Big thanks to @miketaylr for the html5 forms expertise. miketaylr.com/
  660. Modernizr['inputtypes'] = (function(props) {
  661. for ( var i = 0, bool, inputElemType, defaultView, len = props.length; i < len; i++ ) {
  662. inputElem.setAttribute('type', inputElemType = props[i]);
  663. bool = inputElem.type !== 'text';
  664. // We first check to see if the type we give it sticks..
  665. // If the type does, we feed it a textual value, which shouldn't be valid.
  666. // If the value doesn't stick, we know there's input sanitization which infers a custom UI
  667. if ( bool ) {
  668. inputElem.value = smile;
  669. inputElem.style.cssText = 'position:absolute;visibility:hidden;';
  670. if ( /^range$/.test(inputElemType) && inputElem.style.WebkitAppearance !== undefined ) {
  671. docElement.appendChild(inputElem);
  672. defaultView = document.defaultView;
  673. // Safari 2-4 allows the smiley as a value, despite making a slider
  674. bool = defaultView.getComputedStyle &&
  675. defaultView.getComputedStyle(inputElem, null).WebkitAppearance !== 'textfield' &&
  676. // Mobile android web browser has false positive, so must
  677. // check the height to see if the widget is actually there.
  678. (inputElem.offsetHeight !== 0);
  679. docElement.removeChild(inputElem);
  680. } else if ( /^(search|tel)$/.test(inputElemType) ){
  681. // Spec doesn't define any special parsing or detectable UI
  682. // behaviors so we pass these through as true
  683. // Interestingly, opera fails the earlier test, so it doesn't
  684. // even make it here.
  685. } else if ( /^(url|email)$/.test(inputElemType) ) {
  686. // Real url and email support comes with prebaked validation.
  687. bool = inputElem.checkValidity && inputElem.checkValidity() === false;
  688. } else {
  689. // If the upgraded input compontent rejects the :) text, we got a winner
  690. bool = inputElem.value != smile;
  691. }
  692. }
  693. inputs[ props[i] ] = !!bool;
  694. }
  695. return inputs;
  696. })('search tel url email datetime date month week time datetime-local number range color'.split(' '));
  697. /*>>inputtypes*/
  698. }
  699. /*>>webforms*/
  700. // End of test definitions
  701. // -----------------------
  702. // Run through all tests and detect their support in the current UA.
  703. // todo: hypothetically we could be doing an array of tests and use a basic loop here.
  704. for ( var feature in tests ) {
  705. if ( hasOwnProperty(tests, feature) ) {
  706. // run the test, throw the return value into the Modernizr,
  707. // then based on that boolean, define an appropriate className
  708. // and push it into an array of classes we'll join later.
  709. featureName = feature.toLowerCase();
  710. Modernizr[featureName] = tests[feature]();
  711. classes.push((Modernizr[featureName] ? '' : 'no-') + featureName);
  712. }
  713. }
  714. /*>>webforms*/
  715. // input tests need to run.
  716. Modernizr.input || webforms();
  717. /*>>webforms*/
  718. /*>>addtest*/
  719. /**
  720. * addTest allows the user to define their own feature tests
  721. * the result will be added onto the Modernizr object,
  722. * as well as an appropriate className set on the html element
  723. *
  724. * @param feature - String naming the feature
  725. * @param test - Function returning true if feature is supported, false if not
  726. */
  727. Modernizr.addTest = function ( feature, test ) {
  728. if ( typeof feature == 'object' ) {
  729. for ( var key in feature ) {
  730. if ( hasOwnProperty( feature, key ) ) {
  731. Modernizr.addTest( key, feature[ key ] );
  732. }
  733. }
  734. } else {
  735. feature = feature.toLowerCase();
  736. if ( Modernizr[feature] !== undefined ) {
  737. // we're going to quit if you're trying to overwrite an existing test
  738. // if we were to allow it, we'd do this:
  739. // var re = new RegExp("\\b(no-)?" + feature + "\\b");
  740. // docElement.className = docElement.className.replace( re, '' );
  741. // but, no rly, stuff 'em.
  742. return Modernizr;
  743. }
  744. test = typeof test == 'function' ? test() : test;
  745. if (enableClasses) {
  746. docElement.className += ' ' + (test ? '' : 'no-') + feature;
  747. }
  748. Modernizr[feature] = test;
  749. }
  750. return Modernizr; // allow chaining.
  751. };
  752. /*>>addtest*/
  753. // Reset modElem.cssText to nothing to reduce memory footprint.
  754. setCss('');
  755. modElem = inputElem = null;
  756. /*>>shiv*/
  757. /*! HTML5 Shiv v3.5 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed */
  758. ;(function(window, document) {
  759. /** Preset options */
  760. var options = window.html5 || {};
  761. /** Used to skip problem elements */
  762. var reSkip = /^<|^(?:button|form|map|select|textarea|object|iframe|option|optgroup)$/i;
  763. /** Not all elements can be cloned in IE (this list can be shortend) **/
  764. var saveClones = /^<|^(?:a|b|button|code|div|fieldset|form|h1|h2|h3|h4|h5|h6|i|iframe|img|input|label|li|link|ol|option|p|param|q|script|select|span|strong|style|table|tbody|td|textarea|tfoot|th|thead|tr|ul)$/i;
  765. /** Detect whether the browser supports default html5 styles */
  766. var supportsHtml5Styles;
  767. /** Detect whether the browser supports unknown elements */
  768. var supportsUnknownElements;
  769. (function() {
  770. var a = document.createElement('a');
  771. a.innerHTML = '<xyz></xyz>';
  772. //if the hidden property is implemented we can assume, that the browser supports HTML5 Styles | this fails in Chrome 8
  773. supportsHtml5Styles = ('hidden' in a);
  774. //if we are part of Modernizr, we do an additional test to solve the Chrome 8 fail
  775. if(supportsHtml5Styles && typeof injectElementWithStyles == 'function'){
  776. injectElementWithStyles('#modernizr{}', function(node){
  777. node.hidden = true;
  778. supportsHtml5Styles = (window.getComputedStyle ?
  779. getComputedStyle(node, null) :
  780. node.currentStyle).display == 'none';
  781. });
  782. }
  783. supportsUnknownElements = a.childNodes.length == 1 || (function() {
  784. // assign a false positive if unable to shiv
  785. try {
  786. (document.createElement)('a');
  787. } catch(e) {
  788. return true;
  789. }
  790. var frag = document.createDocumentFragment();
  791. return (
  792. typeof frag.cloneNode == 'undefined' ||
  793. typeof frag.createDocumentFragment == 'undefined' ||
  794. typeof frag.createElement == 'undefined'
  795. );
  796. }());
  797. }());
  798. /*--------------------------------------------------------------------------*/
  799. /**
  800. * Creates a style sheet with the given CSS text and adds it to the document.
  801. * @private
  802. * @param {Document} ownerDocument The document.
  803. * @param {String} cssText The CSS text.
  804. * @returns {StyleSheet} The style element.
  805. */
  806. function addStyleSheet(ownerDocument, cssText) {
  807. var p = ownerDocument.createElement('p'),
  808. parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement;
  809. p.innerHTML = 'x<style>' + cssText + '</style>';
  810. return parent.insertBefore(p.lastChild, parent.firstChild);
  811. }
  812. /**
  813. * Returns the value of `html5.elements` as an array.
  814. * @private
  815. * @returns {Array} An array of shived element node names.
  816. */
  817. function getElements() {
  818. var elements = html5.elements;
  819. return typeof elements == 'string' ? elements.split(' ') : elements;
  820. }
  821. /**
  822. * Shivs the `createElement` and `createDocumentFragment` methods of the document.
  823. * @private
  824. * @param {Document|DocumentFragment} ownerDocument The document.
  825. */
  826. function shivMethods(ownerDocument) {
  827. var cache = {},
  828. docCreateElement = ownerDocument.createElement,
  829. docCreateFragment = ownerDocument.createDocumentFragment,
  830. frag = docCreateFragment();
  831. ownerDocument.createElement = function(nodeName) {
  832. //abort shiv
  833. if(!html5.shivMethods){
  834. return docCreateElement(nodeName);
  835. }
  836. var node;
  837. if(cache[nodeName]){
  838. node = cache[nodeName].cloneNode();
  839. } else if(saveClones.test(nodeName)){
  840. node = (cache[nodeName] = docCreateElement(nodeName)).cloneNode();
  841. } else {
  842. node = docCreateElement(nodeName);
  843. }
  844. // Avoid adding some elements to fragments in IE < 9 because
  845. // * Attributes like `name` or `type` cannot be set/changed once an element
  846. // is inserted into a document/fragment
  847. // * Link elements with `src` attributes that are inaccessible, as with
  848. // a 403 response, will cause the tab/window to crash
  849. // * Script elements appended to fragments will execute when their `src`
  850. // or `text` property is set
  851. return node.canHaveChildren && !reSkip.test(nodeName) ? frag.appendChild(node) : node;
  852. };
  853. ownerDocument.createDocumentFragment = Function('h,f', 'return function(){' +
  854. 'var n=f.cloneNode(),c=n.createElement;' +
  855. 'h.shivMethods&&(' +
  856. // unroll the `createElement` calls
  857. getElements().join().replace(/\w+/g, function(nodeName) {
  858. docCreateElement(nodeName);
  859. frag.createElement(nodeName);
  860. return 'c("' + nodeName + '")';
  861. }) +
  862. ');return n}'
  863. )(html5, frag);
  864. }
  865. /*--------------------------------------------------------------------------*/
  866. /**
  867. * Shivs the given document.
  868. * @memberOf html5
  869. * @param {Document} ownerDocument The document to shiv.
  870. * @returns {Document} The shived document.
  871. */
  872. function shivDocument(ownerDocument) {
  873. var shived;
  874. if (ownerDocument.documentShived) {
  875. return ownerDocument;
  876. }
  877. if (html5.shivCSS && !supportsHtml5Styles) {
  878. shived = !!addStyleSheet(ownerDocument,
  879. // corrects block display not defined in IE6/7/8/9
  880. 'article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}' +
  881. // corrects audio display not defined in IE6/7/8/9
  882. 'audio{display:none}' +
  883. // corrects canvas and video display not defined in IE6/7/8/9
  884. 'canvas,video{display:inline-block;*display:inline;*zoom:1}' +
  885. // corrects 'hidden' attribute and audio[controls] display not present in IE7/8/9
  886. '[hidden]{display:none}audio[controls]{display:inline-block;*display:inline;*zoom:1}' +
  887. // adds styling not present in IE6/7/8/9
  888. 'mark{background:#FF0;color:#000}'
  889. );
  890. }
  891. if (!supportsUnknownElements) {
  892. shived = !shivMethods(ownerDocument);
  893. }
  894. if (shived) {
  895. ownerDocument.documentShived = shived;
  896. }
  897. return ownerDocument;
  898. }
  899. /*--------------------------------------------------------------------------*/
  900. /**
  901. * The `html5` object is exposed so that more elements can be shived and
  902. * existing shiving can be detected on iframes.
  903. * @type Object
  904. * @example
  905. *
  906. * // options can be changed before the script is included
  907. * html5 = { 'elements': 'mark section', 'shivCSS': false, 'shivMethods': false };
  908. */
  909. var html5 = {
  910. /**
  911. * An array or space separated string of node names of the elements to shiv.
  912. * @memberOf html5
  913. * @type Array|String
  914. */
  915. 'elements': options.elements || 'abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video',
  916. /**
  917. * A flag to indicate that the HTML5 style sheet should be inserted.
  918. * @memberOf html5
  919. * @type Boolean
  920. */
  921. 'shivCSS': !(options.shivCSS === false),
  922. /**
  923. * A flag to indicate that the document's `createElement` and `createDocumentFragment`
  924. * methods should be overwritten.
  925. * @memberOf html5
  926. * @type Boolean
  927. */
  928. 'shivMethods': !(options.shivMethods === false),
  929. /**
  930. * A string to describe the type of `html5` object ("default" or "default print").
  931. * @memberOf html5
  932. * @type String
  933. */
  934. 'type': 'default',
  935. // shivs the document according to the specified `html5` object options
  936. 'shivDocument': shivDocument
  937. };
  938. /*--------------------------------------------------------------------------*/
  939. // expose html5
  940. window.html5 = html5;
  941. // shiv the document
  942. shivDocument(document);
  943. }(this, document));
  944. /*>>shiv*/
  945. // Assign private properties to the return object with prefix
  946. Modernizr._version = version;
  947. // expose these for the plugin API. Look in the source for how to join() them against your input
  948. /*>>prefixes*/
  949. Modernizr._prefixes = prefixes;
  950. /*>>prefixes*/
  951. /*>>domprefixes*/
  952. Modernizr._domPrefixes = domPrefixes;
  953. Modernizr._cssomPrefixes = cssomPrefixes;
  954. /*>>domprefixes*/
  955. /*>>mq*/
  956. // Modernizr.mq tests a given media query, live against the current state of the window
  957. // A few important notes:
  958. // * If a browser does not support media queries at all (eg. oldIE) the mq() will always return false
  959. // * A max-width or orientation query will be evaluated against the current state, which may change later.
  960. // * You must specify values. Eg. If you are testing support for the min-width media query use:
  961. // Modernizr.mq('(min-width:0)')
  962. // usage:
  963. // Modernizr.mq('only screen and (max-width:768)')
  964. Modernizr.mq = testMediaQuery;
  965. /*>>mq*/
  966. /*>>hasevent*/
  967. // Modernizr.hasEvent() detects support for a given event, with an optional element to test on
  968. // Modernizr.hasEvent('gesturestart', elem)
  969. Modernizr.hasEvent = isEventSupported;
  970. /*>>hasevent*/
  971. /*>>testprop*/
  972. // Modernizr.testProp() investigates whether a given style property is recognized
  973. // Note that the property names must be provided in the camelCase variant.
  974. // Modernizr.testProp('pointerEvents')
  975. Modernizr.testProp = function(prop){
  976. return testProps([prop]);
  977. };
  978. /*>>testprop*/
  979. /*>>testallprops*/
  980. // Modernizr.testAllProps() investigates whether a given style property,
  981. // or any of its vendor-prefixed variants, is recognized
  982. // Note that the property names must be provided in the camelCase variant.
  983. // Modernizr.testAllProps('boxSizing')
  984. Modernizr.testAllProps = testPropsAll;
  985. /*>>testallprops*/
  986. /*>>teststyles*/
  987. // Modernizr.testStyles() allows you to add custom styles to the document and test an element afterwards
  988. // Modernizr.testStyles('#modernizr { position:absolute }', function(elem, rule){ ... })
  989. Modernizr.testStyles = injectElementWithStyles;
  990. /*>>teststyles*/
  991. /*>>prefixed*/
  992. // Modernizr.prefixed() returns the prefixed or nonprefixed property name variant of your input
  993. // Modernizr.prefixed('boxSizing') // 'MozBoxSizing'
  994. // Properties must be passed as dom-style camelcase, rather than `box-sizing` hypentated style.
  995. // Return values will also be the camelCase variant, if you need to translate that to hypenated style use:
  996. //
  997. // str.replace(/([A-Z])/g, function(str,m1){ return '-' + m1.toLowerCase(); }).replace(/^ms-/,'-ms-');
  998. // If you're trying to ascertain which transition end event to bind to, you might do something like...
  999. //
  1000. // var transEndEventNames = {
  1001. // 'WebkitTransition' : 'webkitTransitionEnd',
  1002. // 'MozTransition' : 'transitionend',
  1003. // 'OTransition' : 'oTransitionEnd',
  1004. // 'msTransition' : 'MSTransitionEnd',
  1005. // 'transition' : 'transitionend'
  1006. // },
  1007. // transEndEventName = transEndEventNames[ Modernizr.prefixed('transition') ];
  1008. Modernizr.prefixed = function(prop, obj, elem){
  1009. if(!obj) {
  1010. return testPropsAll(prop, 'pfx');
  1011. } else {
  1012. // Testing DOM property e.g. Modernizr.prefixed('requestAnimationFrame', window) // 'mozRequestAnimationFrame'
  1013. return testPropsAll(prop, obj, elem);
  1014. }
  1015. };
  1016. /*>>prefixed*/
  1017. /*>>cssclasses*/
  1018. // Remove "no-js" class from <html> element, if it exists:
  1019. docElement.className = docElement.className.replace(/(^|\s)no-js(\s|$)/, '$1$2') +
  1020. // Add the new classes to the <html> element.
  1021. (enableClasses ? ' js ' + classes.join(' ') : '');
  1022. /*>>cssclasses*/
  1023. return Modernizr;
  1024. })(this, this.document);