From b7c56173c206f884999fcd8036a21bad59d5cee6 Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Wed, 6 Dec 2017 14:54:27 -0800 Subject: [PATCH] Use padding-top to get correct computed style on older safari Because the element wasn't floating, `top: 10px` was not showing up in computed styles on Safari 9 and 10 --- lib/mixins/element-mixin.html | 8 ++++---- test/unit/styling-scoped.html | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/mixins/element-mixin.html b/lib/mixins/element-mixin.html index 419209b624..2b51ac2bfe 100644 --- a/lib/mixins/element-mixin.html +++ b/lib/mixins/element-mixin.html @@ -417,18 +417,18 @@ function processElementStyles(klass, template, is, baseURI) { const styles = Polymer.StyleGather.stylesFromModuleImports(is).concat( Polymer.StyleGather.stylesFromTemplate(template)); - const templateStyles = Array.from(template.content.querySelectorAll('style')); + const templateStyles = template.content.querySelectorAll('style'); // keep track of the last "concrete" style in the template we have encountered let templateStyleIndex = 0; // ensure all gathered styles are actually in this template. for (let i=0; i < styles.length; i++) { let s = styles[i]; + let templateStyle = templateStyles[templateStyleIndex]; // if the style is not in this template, it's been "included" and // we put a clone of it in the template before the style that included it - if (templateStyles.indexOf(s) === -1) { + if (templateStyle !== s) { s = s.cloneNode(true); - let importingTemplateStyle = templateStyles[templateStyleIndex]; - importingTemplateStyle.parentNode.insertBefore(s, importingTemplateStyle); + templateStyle.parentNode.insertBefore(s, templateStyle); } else { templateStyleIndex++; } diff --git a/test/unit/styling-scoped.html b/test/unit/styling-scoped.html index 7859aa5444..3eb3bf0996 100644 --- a/test/unit/styling-scoped.html +++ b/test/unit/styling-scoped.html @@ -660,10 +660,20 @@ + + + +