diff options
author | Brian Picciano <mediocregopher@gmail.com> | 2018-11-13 00:24:09 -0500 |
---|---|---|
committer | Brian Picciano <mediocregopher@gmail.com> | 2018-11-13 00:24:09 -0500 |
commit | 2b4757367470d8e36bc00901dac567e375796ed4 (patch) | |
tree | 72368624006c21d28228a100ee88590c7bf95e58 /assets/viz/2/goog/events/browserfeature.js | |
parent | 5ed62d23b4bbbf7717de4adfa0eaf2af19365408 (diff) |
update viz 2 to use the newest version, which has some performance improvements and is easier to read the code for. also update the description
Diffstat (limited to 'assets/viz/2/goog/events/browserfeature.js')
-rw-r--r-- | assets/viz/2/goog/events/browserfeature.js | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/assets/viz/2/goog/events/browserfeature.js b/assets/viz/2/goog/events/browserfeature.js index 4cfa8e3..7cc7bd6 100644 --- a/assets/viz/2/goog/events/browserfeature.js +++ b/assets/viz/2/goog/events/browserfeature.js @@ -21,6 +21,8 @@ goog.provide('goog.events.BrowserFeature'); goog.require('goog.userAgent'); +goog.scope(function() { + /** @@ -80,5 +82,41 @@ goog.events.BrowserFeature = { 'ontouchstart' in document.documentElement) || // IE10 uses non-standard touch events, so it has a different check. !!(goog.global['navigator'] && - goog.global['navigator']['msMaxTouchPoints'])) + goog.global['navigator']['msMaxTouchPoints'])), + + /** + * Whether addEventListener supports {passive: true}. + * https://developers.google.com/web/updates/2016/06/passive-event-listeners + */ + PASSIVE_EVENTS: purify(function() { + // If we're in a web worker or other custom environment, we can't tell. + if (!goog.global.addEventListener || !Object.defineProperty) { // IE 8 + return false; + } + + var passive = false; + var options = Object.defineProperty({}, 'passive', { + get: function() { + passive = true; + } + }); + goog.global.addEventListener('test', goog.nullFunction, options); + goog.global.removeEventListener('test', goog.nullFunction, options); + + return passive; + }) }; + + +/** + * Tricks Closure Compiler into believing that a function is pure. The compiler + * assumes that any `valueOf` function is pure, without analyzing its contents. + * + * @param {function(): T} fn + * @return {T} + * @template T + */ +function purify(fn) { + return ({valueOf: fn}).valueOf(); +} +}); // goog.scope |