From 124d878ea87790779f8974f90ec45b3354123c11 Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Wed, 9 Oct 2019 10:37:20 -0700 Subject: [PATCH] Changes based on review. --- lib/utils/settings.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/utils/settings.js b/lib/utils/settings.js index eb169524c7..380c7d9928 100644 --- a/lib/utils/settings.js +++ b/lib/utils/settings.js @@ -8,15 +8,26 @@ Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ import './boot.js'; - import { pathFromUrl } from './resolve-url.js'; export const useShadow = !(window.ShadyDOM) || !(window.ShadyDOM.inUse); export const useNativeCSSProperties = Boolean(!window.ShadyCSS || window.ShadyCSS.nativeCss); export const useNativeCustomElements = !(window.customElements.polyfillWrapFlushCallback); export const supportsAdoptingStyleSheets = useShadow && ('adoptedStyleSheets' in Document.prototype) && - ('replaceSync' in CSSStyleSheet.prototype); - + ('replaceSync' in CSSStyleSheet.prototype) && + // Since space may change, feature detect exact API we need + (() => { + try { + const sheet = new CSSStyleSheet(); + sheet.replaceSync(''); + const host = document.createElement('div'); + host.attachShadow({mode: 'open'}); + host.shadowRoot.adoptedStyleSheets = [sheet]; + return (host.shadowRoot.adoptedStyleSheets[0] === sheet); + } catch(e) { + return false; + } + })(); /** * Globally settable property that is automatically assigned to