• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2@license
3Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
4This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7Code distributed by Google as part of the polymer project is also
8subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9*/
10
11'use strict';
12
13import ScopingShim from '../src/scoping-shim.js';
14import {nativeCssVariables, nativeShadow, cssBuild} from '../src/style-settings.js';
15
16/** @const {ScopingShim} */
17const scopingShim = new ScopingShim();
18
19let ApplyShim, CustomStyleInterface;
20
21if (window['ShadyCSS']) {
22  ApplyShim = window['ShadyCSS']['ApplyShim'];
23  CustomStyleInterface = window['ShadyCSS']['CustomStyleInterface'];
24}
25
26window.ShadyCSS = {
27  ScopingShim: scopingShim,
28  /**
29   * @param {!HTMLTemplateElement} template
30   * @param {string} elementName
31   * @param {string=} elementExtends
32   */
33  prepareTemplate(template, elementName, elementExtends) {
34    scopingShim.flushCustomStyles();
35    scopingShim.prepareTemplate(template, elementName, elementExtends)
36  },
37
38  /**
39   * @param {!HTMLTemplateElement} template
40   * @param {string} elementName
41   */
42  prepareTemplateDom(template, elementName) {
43    scopingShim.prepareTemplateDom(template, elementName);
44  },
45
46  /**
47   * @param {!HTMLTemplateElement} template
48   * @param {string} elementName
49   * @param {string=} elementExtends
50   */
51  prepareTemplateStyles(template, elementName, elementExtends) {
52    scopingShim.flushCustomStyles();
53    scopingShim.prepareTemplateStyles(template, elementName, elementExtends)
54  },
55  /**
56   * @param {!HTMLElement} element
57   * @param {Object=} properties
58   */
59  styleSubtree(element, properties) {
60    scopingShim.flushCustomStyles();
61    scopingShim.styleSubtree(element, properties);
62  },
63
64  /**
65   * @param {!HTMLElement} element
66   */
67  styleElement(element) {
68    scopingShim.flushCustomStyles();
69    scopingShim.styleElement(element);
70  },
71
72  /**
73   * @param {Object=} properties
74   */
75  styleDocument(properties) {
76    scopingShim.flushCustomStyles();
77    scopingShim.styleDocument(properties);
78  },
79
80  flushCustomStyles() {
81    scopingShim.flushCustomStyles();
82  },
83
84  /**
85   * @param {Element} element
86   * @param {string} property
87   * @return {string}
88   */
89  getComputedStyleValue(element, property) {
90    return scopingShim.getComputedStyleValue(element, property);
91  },
92
93  nativeCss: nativeCssVariables,
94
95  nativeShadow: nativeShadow,
96
97  cssBuild: cssBuild
98};
99
100if (ApplyShim) {
101  window.ShadyCSS.ApplyShim = ApplyShim;
102}
103
104if (CustomStyleInterface) {
105  window.ShadyCSS.CustomStyleInterface = CustomStyleInterface;
106}