Skip to content

Commit

Permalink
refactor: reuse existing style scope info (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan committed Feb 25, 2019
1 parent 784dadf commit 929101d
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/vaadin-overlay.html
Original file line number Diff line number Diff line change
Expand Up @@ -787,18 +787,12 @@
this.$.content.attachShadow({mode: 'open'});
}

let scopeCssText = Array.from(templateRoot.querySelectorAll('style'))
.reduce((result, style) => result + style.textContent, '');

if (window.ShadyCSS && !window.ShadyCSS.nativeShadow) {
// 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 += '}';
}
let scopeCssText = '';
const host = templateRoot.host;
if (host && host.constructor.template) {
scopeCssText = Polymer.StyleGather
.stylesFromTemplate(host.constructor.template)
.reduce((result, style) => result + style.textContent, '');
}

// The overlay root’s :host styles should not apply inside the overlay
Expand Down

0 comments on commit 929101d

Please sign in to comment.