• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
12<script src=".././test-flags.js"></script>
13<script src="../../node_modules/@webcomponents/webcomponents-platform/webcomponents-platform.js"></script>
14<script src="../../node_modules/es6-promise/dist/es6-promise.auto.min.js"></script>
15<script src="../../node_modules/@webcomponents/template/template.js"></script>
16<script src="../../node_modules/@webcomponents/html-imports/html-imports.min.js"></script>
17<script>
18  WCT = { waitFor: function (cb) { HTMLImports.whenReady(cb) } }
19</script>
20<script src="../../node_modules/@webcomponents/shadydom/shadydom.min.js"></script>
21<script src="../../node_modules/@webcomponents/custom-elements/custom-elements.min.js"></script>
22<script>
23  if (window.customElements && customElements.polyfillWrapFlushCallback) {
24    // delay definition of custom-style until after template polyfill loads
25    customElements.polyfillWrapFlushCallback(function (cb) {
26      HTMLImports.whenReady(cb);
27    });
28  }
29</script>
30<script src="../../scoping-shim.min.js"></script>
31<script src="../../custom-style-interface.min.js"></script>
32<script src="../module/generated/make-element.js"></script>
33<script src="../module/generated/custom-style-element.js"></script>
34<script src="../../node_modules/wct-browser-legacy/browser.js"></script>
35
36<custom-style>
37  <style>
38    #target {
39      display: block;
40      border: var(--late);
41    }
42  </style>
43</custom-style>
44
45<template id="late">
46  <custom-style class="late-style">
47    <style>
48    html {
49      --late: 2px solid red;
50    }
51    </style>
52  </custom-style>
53</template>
54
55<div id="target"></div>
56
57<script>
58suite('custom-style only', function() {
59  var host = document.querySelector('#target');
60  test('custom-style by itself works as expected', function() {
61    assert.equal(getComputedStyle(host).getPropertyValue('display').trim(), 'block');
62  });
63  test('late custom-style updates styling', function(done) {
64    var lateTemplate = document.querySelector('template#late');
65    document.body.appendChild(document.importNode(lateTemplate.content, true));
66    // two rAF to wait for after custom-style-interface's batching
67    requestAnimationFrame(function() {
68      requestAnimationFrame(function() {
69        assert.equal(getComputedStyle(host).borderTopWidth.trim(), '2px');
70        done();
71      });
72    });
73  })
74})
75</script>