From fabdbc3b6172e4d4eb9b516a2a620af1147eb9b3 Mon Sep 17 00:00:00 2001 From: Caleb James DeLisle Date: Thu, 12 Jul 2018 16:02:46 +0200 Subject: [PATCH] Add a feedback test for checking for CSS variables, so we won't use a feature which is not implemented by the vast majority of the people using CryptPad... --- www/common/cryptpad-common.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 574a696c3..69c67fdc5 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -834,6 +834,20 @@ define([ LOADING_DRIVE: common.loading.onDriveEvent.fire }; + common.hasCSSVariables = function () { + if (window.CSS && window.CSS.supports && window.CSS.supports('--a', 0)) { return true; } + // Safari lol y u always b returnin false ? + var color = 'rgb(255, 198, 0)'; + var el = document.createElement('span'); + el.style.setProperty('--color', color); + el.style.setProperty('background', 'var(--color)'); + document.body.appendChild(el); + var styles = getComputedStyle(el); + document.body.removeChild(el); + var doesSupport = (styles.backgroundColor === color); + return doesSupport; + }; + common.ready = (function () { var env = {}; var initialized = false; @@ -873,6 +887,9 @@ define([ if (typeof(ServiceWorker) === "undefined") { Feedback.send('NO_SERVICEWORKER'); } + if (!common.hasCSSVariables()) { + Feedback.send('NO_CSS_VARIABLES'); + } Feedback.reportScreenDimensions(); Feedback.reportLanguage();