| OLD | NEW |
| (Empty) | |
| 1 <!-- |
| 2 @license |
| 3 Copyright (c) 2017 The Polymer Project Authors. All rights reserved. |
| 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 7 Code distributed by Google as part of the polymer project is also |
| 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 9 --> |
| 10 |
| 11 <script> |
| 12 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Co
nstructor)) { throw new TypeError("Cannot call a class as a function"); } } |
| 13 function _possibleConstructorReturn(self, call) { if (!self) { throw new Refer
enceError("this hasn't been initialised - super() hasn't been called"); } return
call && (typeof call === "object" || typeof call === "function") ? call : self;
} |
| 14 function _inherits(subClass, superClass) { if (typeof superClass !== "function
" && superClass !== null) { throw new TypeError("Super expression must either be
null or a function, not " + typeof superClass); } subClass.prototype = Object.c
reate(superClass && superClass.prototype, { constructor: { value: subClass, enum
erable: false, writable: true, configurable: true } }); if (superClass) Object.s
etPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__
= superClass; } |
| 15 |
| 16 // Kick off shady CSS. |
| 17 var template = document.createElement('template'); |
| 18 template.innerHTML = |
| 19 ` |
| 20 <style>:host {color: blue;} .red-text {color: red;} </style> |
| 21 <p class="red-text">Shadow DOM</p> |
| 22 <slot id="slot"></slot> |
| 23 `; |
| 24 if (template) { |
| 25 if (window.ShadyCSS) { |
| 26 window.ShadyCSS.prepareTemplate(template, 'simple-element'); |
| 27 } |
| 28 } |
| 29 |
| 30 var SimpleElement = function (_HTMLElement) { |
| 31 _inherits(SimpleElement, _HTMLElement); |
| 32 |
| 33 function SimpleElement() { |
| 34 _classCallCheck(this, SimpleElement); |
| 35 |
| 36 var _this = _possibleConstructorReturn(this, (SimpleElement.__proto__ || O
bject.getPrototypeOf(SimpleElement)).call(this)); |
| 37 |
| 38 _this.bestName = 'batman'; |
| 39 if (window.ShadyCSS) { |
| 40 window.ShadyCSS.styleElement(_this); |
| 41 } |
| 42 |
| 43 if (template && !_this.shadowRoot) { |
| 44 _this.attachShadow({ mode: 'open' }); |
| 45 _this.shadowRoot.appendChild(document.importNode(template.content, true)
); |
| 46 } |
| 47 return _this; |
| 48 } |
| 49 |
| 50 return SimpleElement; |
| 51 }(HTMLElement); |
| 52 |
| 53 window.customElements.define('simple-element', SimpleElement); |
| 54 </script> |
| OLD | NEW |