1/** 2@license 3Copyright (c) 2017 The Polymer Project Authors. All rights reserved. 4This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 5The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 6The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 7Code distributed by Google as part of the polymer project is also 8subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 9*/ 10 11'use strict'; 12 13export const nativeShadow = !(window['ShadyDOM'] && window['ShadyDOM']['inUse']); 14let nativeCssVariables_; 15 16/** 17 * @param {(ShadyCSSOptions | ShadyCSSInterface)=} settings 18 */ 19function calcCssVariables(settings) { 20 if (settings && settings['shimcssproperties']) { 21 nativeCssVariables_ = false; 22 } else { 23 // chrome 49 has semi-working css vars, check if box-shadow works 24 // safari 9.1 has a recalc bug: https://bugs.webkit.org/show_bug.cgi?id=155782 25 // However, shim css custom properties are only supported with ShadyDOM enabled, 26 // so fall back on native if we do not detect ShadyDOM 27 // Edge 15: custom properties used in ::before and ::after will also be used in the parent element 28 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/12414257/ 29 nativeCssVariables_ = nativeShadow || Boolean(!navigator.userAgent.match(/AppleWebKit\/601|Edge\/15/) && 30 window.CSS && CSS.supports && CSS.supports('box-shadow', '0 0 0 var(--foo)')); 31 } 32} 33 34/** @type {string | undefined} */ 35export let cssBuild; 36if (window.ShadyCSS && window.ShadyCSS.cssBuild !== undefined) { 37 cssBuild = window.ShadyCSS.cssBuild; 38} 39 40if (window.ShadyCSS && window.ShadyCSS.nativeCss !== undefined) { 41 nativeCssVariables_ = window.ShadyCSS.nativeCss; 42} else if (window.ShadyCSS) { 43 calcCssVariables(window.ShadyCSS); 44 // reset window variable to let ShadyCSS API take its place 45 window.ShadyCSS = undefined; 46} else { 47 calcCssVariables(window['WebComponents'] && window['WebComponents']['flags']); 48} 49 50// Hack for type error under new type inference which doesn't like that 51// nativeCssVariables is updated in a function and assigns the type 52// `function(): ?` instead of `boolean`. 53export const nativeCssVariables = /** @type {boolean} */(nativeCssVariables_);