From 706e602162d725a4e1d2489f3d57f66db584f9d0 Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Tue, 12 Dec 2017 11:42:37 -0800 Subject: [PATCH 1/2] Fix regression with imported css Fix case where `` is the only styling for an element Fixes #4986 --- lib/mixins/element-mixin.html | 4 +++- test/unit/styling-scoped.html | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/mixins/element-mixin.html b/lib/mixins/element-mixin.html index 87c77db15e..9ed49774b1 100644 --- a/lib/mixins/element-mixin.html +++ b/lib/mixins/element-mixin.html @@ -255,7 +255,9 @@ // 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 no styles in the template, fall back to first element child of template + let templateStyle = templateStyles.length ? + templateStyles[templateStyleIndex] : template.content.firstElementChild; // 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 (templateStyle !== s) { diff --git a/test/unit/styling-scoped.html b/test/unit/styling-scoped.html index 656a8ec119..ffbc4502b6 100644 --- a/test/unit/styling-scoped.html +++ b/test/unit/styling-scoped.html @@ -715,6 +715,21 @@ + + + + + +