diff --git a/src/lib/style-util.html b/src/lib/style-util.html index a9456a88f0..1fd3845f42 100644 --- a/src/lib/style-util.html +++ b/src/lib/style-util.html @@ -228,7 +228,7 @@ for (var i=0, s; i < styles.length; i++) { s = styles[i]; s.parentNode.insertBefore( - this._includesToFragment(s.getAttribute('include')), s.nextSibling); + this._includesToFragment(s.getAttribute('include')), s); } }, @@ -248,13 +248,14 @@ var s$ = source.querySelectorAll('style'); for (var i=0, s; i < s$.length; i++) { s = s$[i]; - if (s.textContent) { - frag.appendChild(s.cloneNode(true)); - } var include = s.getAttribute('include'); if (include) { frag.appendChild(this._includesToFragment(include)); } + if (s.textContent) { + frag.appendChild(s.cloneNode(true)); + } + } }, diff --git a/test/runner.html b/test/runner.html index f44d0a8c9b..484c778a42 100644 --- a/test/runner.html +++ b/test/runner.html @@ -58,6 +58,7 @@ 'unit/resolveurl.html', 'unit/css-parse.html', 'unit/styling-scoped.html', + 'unit/preserve-style-include/styling-scoped.html', 'unit/styling-extends.html', 'unit/styling-remote.html', 'unit/styling-cross-scope-var.html', diff --git a/test/smoke/preserve-include.html b/test/smoke/preserve-include.html index 61c42eb563..e74632cb3e 100644 --- a/test/smoke/preserve-include.html +++ b/test/smoke/preserve-include.html @@ -16,6 +16,9 @@ @@ -50,6 +53,7 @@ :host { display: block; background: green; + @apply --mixin; } diff --git a/test/unit/preserve-style-include/styling-scoped-elements-built.html b/test/unit/preserve-style-include/styling-scoped-elements-built.html new file mode 100644 index 0000000000..b0e7840a38 --- /dev/null +++ b/test/unit/preserve-style-include/styling-scoped-elements-built.html @@ -0,0 +1,709 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/unit/preserve-style-include/styling-scoped.html b/test/unit/preserve-style-include/styling-scoped.html new file mode 100644 index 0000000000..a6b5aa9e60 --- /dev/null +++ b/test/unit/preserve-style-include/styling-scoped.html @@ -0,0 +1,382 @@ + + + + + + + + + + + + + + +
no margin
+ + +
Foo
+
Bar
+
Content
+
+ + + + + + + + + + + + + +
+
+
+ + + +
+
+ + + + + + +