diff options
author | xjm <xjm@65776.no-reply.drupal.org> | 2020-01-17 17:49:59 -0600 |
---|---|---|
committer | xjm <xjm@65776.no-reply.drupal.org> | 2020-01-17 17:49:59 -0600 |
commit | 71fb25e331ade1cadd56305b1e74bf634190b071 (patch) | |
tree | 84bdf22edf40988e1c1501f9e84bf60f4e64fc81 /core/misc/modernizr-additional-tests.es6.js | |
parent | e68ca9358fa3e56ef9ae0746474bc89ffa236d38 (diff) | |
download | drupal-71fb25e331ade1cadd56305b1e74bf634190b071.tar.gz drupal-71fb25e331ade1cadd56305b1e74bf634190b071.zip |
Issue #3100937 by bnjmnm, tedbow, xjm, lauriii: Update modernizr to 3.8.0
Diffstat (limited to 'core/misc/modernizr-additional-tests.es6.js')
-rw-r--r-- | core/misc/modernizr-additional-tests.es6.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/core/misc/modernizr-additional-tests.es6.js b/core/misc/modernizr-additional-tests.es6.js new file mode 100644 index 000000000000..00fb90e936fc --- /dev/null +++ b/core/misc/modernizr-additional-tests.es6.js @@ -0,0 +1,43 @@ +/** + * @file + * Provides additional Modernizr tests. + */ +(Modernizr => { + // This is a copy of Modernizr's touchevents test from version 3.3.1. Drupal + // core has updated Modernizr to a version newer than 3.3.1, but this newer + // version does not include the touchevents test in its build. Modernizr's + // touchevents test is deprecated, and newer versions of this test do not work + // properly with Drupal as it significantly changes the criteria used for + // determining if touchevents are supported. + // The most recent known-to-work version, 3.3.1 is provided here. The only + // changes are refactoring the code to meet Drupal's JavaScript coding + // standards and calling prefixes and testStyles() via the Modernizr object + // as they are not in scope when adding a test via Modernizr.addTest(); + // @todo find alternative to Modernizr's deprecated touchevent test in + // http://drupal.org/node/3101922 + // @see https://github.com/Modernizr/Modernizr/blob/v3.3.1/feature-detects/touchevents.js + Modernizr.addTest('touchevents', () => { + let bool; + + if ( + 'ontouchstart' in window || + (window.DocumentTouch && document instanceof window.DocumentTouch) + ) { + bool = true; + } else { + // include the 'heartz' as a way to have a non matching MQ to help + // terminate the join https://git.io/vznFH + const query = [ + '@media (', + Modernizr._prefixes.join('touch-enabled),('), + 'heartz', + ')', + '{#modernizr{top:9px;position:absolute}}', + ].join(''); + Modernizr.testStyles(query, node => { + bool = node.offsetTop === 9; + }); + } + return bool; + }); +})(Modernizr); |