Skip to content

Commit

Permalink
fix: revert incorrect style gather optimisation
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan committed May 16, 2019
1 parent 6fea9f6 commit 93227f7
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/vaadin-overlay.html
Expand Up @@ -790,23 +790,31 @@
const _isScoped = templateRoot !== document;

if (_isScoped) {
const isShady = window.ShadyCSS && !window.ShadyCSS.nativeShadow;

if (!this.$.content.shadowRoot) {
this.$.content.attachShadow({mode: 'open'});
}

let scopeCssText = '';
const host = templateRoot.host;
if (host && host._template) {
scopeCssText = Polymer.StyleGather
.stylesFromTemplate(host._template)
.reduce((result, style) => result + style.textContent, '');
let scopeCssText = Array.from(templateRoot.querySelectorAll('style'))
.reduce((result, style) => result + style.textContent, '');

if (isShady) {
// NOTE(platosha): ShadyCSS removes <style>’s from templates, so
// we have to use these protected APIs to get their contents back
const styleInfo = window.ShadyCSS.ScopingShim
._styleInfoForNode(templateRoot.host);
if (styleInfo) {
scopeCssText += styleInfo._getStyleRules().parsedCssText;
scopeCssText += '}';
}
}

// The overlay root’s :host styles should not apply inside the overlay
scopeCssText = scopeCssText.replace(/:host/g, ':host-nomatch');

if (scopeCssText) {
if (window.ShadyCSS && !window.ShadyCSS.nativeShadow) {
if (isShady) {
// ShadyDOM: replace the <div part="content"> with a generated
// styled custom element
const contentPart = createOverlayContent(scopeCssText);
Expand Down

0 comments on commit 93227f7

Please sign in to comment.