1<!doctype html>
2<!--
3@license
4Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
5This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
7The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
8Code distributed by Google as part of the polymer project is also
9subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
10-->
11<script>
12WCT = {waitFor: function (cb) {HTMLImports.whenReady(cb)}}
13</script>
14<script src="../../node_modules/wct-browser-legacy/browser.js"></script>
15<script src="../../node_modules/@webcomponents/webcomponents-platform/webcomponents-platform.js"></script>
16<script src="../../node_modules/es6-promise/dist/es6-promise.auto.min.js"></script>
17<script src="../../node_modules/@webcomponents/template/template.js"></script>
18<script src="../../node_modules/@webcomponents/html-imports/html-imports.min.js"></script>
19<script src="../../node_modules/@webcomponents/shadydom/shadydom.min.js"></script>
20<script src="../../node_modules/@webcomponents/custom-elements/custom-elements.min.js"></script>
21<script src="../../apply-shim.min.js"></script>
22<script src="../../custom-style-interface.min.js"></script>
23<script src="../module/generated/make-element.js"></script>
24<script src="../module/generated/custom-style-element.js"></script>
25
26<custom-style>
27  <style>
28  html {
29    --foo: rgb(123, 123, 123);
30    --bar: {
31      border: 2px solid red;
32    }
33  }
34  </style>
35</custom-style>
36
37<template id="x-inner">
38  <style>
39    :host {
40      display: block;
41      height: 100px;
42      width: 100px;
43      border: 4px solid blue;
44      background-color: var(--foo);
45      @apply --bar;
46    }
47  </style>
48</template>
49
50<template id="x-outer">
51  <style>
52  :host {
53    display: block;
54    @apply --bar;
55  }
56  </style>
57  <x-inner></x-inner>
58</template>
59
60<x-outer id="target"></x-outer>
61
62<script>
63  suite('Custom Style upgrades', function() {
64    suiteSetup(function() {
65      makeElement('x-inner');
66      makeElement('x-outer');
67    });
68    test('custom-style applies to deeply nested elements', function() {
69      var target = document.querySelector('#target');
70      var inner = target.shadowRoot.querySelector('x-inner');
71      assert.equal(getComputedStyle(inner).backgroundColor, 'rgb(123, 123, 123)');
72    });
73    test('custom-style applied mixins update', function() {
74      var target = document.querySelector('#target');
75      var inner = target.shadowRoot.querySelector('x-inner');
76      assert.equal(getComputedStyle(target).borderTopWidth.trim(), '2px');
77      assert.equal(getComputedStyle(inner).borderTopWidth.trim(), '2px');
78    });
79  });
80</script>