From 2b4757367470d8e36bc00901dac567e375796ed4 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Tue, 13 Nov 2018 00:24:09 -0500 Subject: 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 --- assets/viz/2/goog/events/browserfeature.js | 40 +++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'assets/viz/2/goog/events/browserfeature.js') 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 -- cgit v1.2.3