1/**
2@license
3Copyright (c) 2016 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/*
12Wrapper over <style> elements to co-operate with ShadyCSS
13
14Example:
15<custom-style>
16  <style>
17  ...
18  </style>
19</custom-style>
20*/
21(function() {
22  'use strict';
23
24  const CustomStyleInterface = window.ShadyCSS.CustomStyleInterface;
25
26  class CustomStyle extends HTMLElement {
27    constructor() {
28      super();
29      this._style = null;
30      CustomStyleInterface.addCustomStyle(this);
31    }
32    getStyle() {
33      if (!this._style) {
34        this._style = this.querySelector('style');
35      }
36      return this._style;
37    }
38  }
39
40  window.CustomStyle = CustomStyle;
41  window.customElements.define('custom-style', CustomStyle);
42})();