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