1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <template id="card-fill">
- <style id="style">
- :host {width:100%; flex: 1;}
- </style>
-
- </template>
-
- <script>
- (function(window, document) {
- var elemName = 'card-fill';
- var mainDoc = document;
- var importDoc = document.currentScript.ownerDocument;
-
- var proto = Object.create(HTMLDivElement.prototype);
- Object.defineProperty(proto, "size", {
- get: function() {
- return "";
- },
- set: function (value) {
- this.setAttribute('size', value);
-
- var root = this.shadowRoot;
- var style = root.getElementById("style");
- style.innerHTML = ":host{width:100%;flex:"+value+"}"
- }
- });
- proto.createdCallback = function () {
- var template = importDoc.getElementById(elemName);
- var clone = mainDoc.importNode(template.content, true);
- var root = this.createShadowRoot();
- root.appendChild(clone);
-
- this.size = this.getAttribute('size') || "1";
- }
- proto.attributeChangedCallback = function (name, oldValue, newValue) {
- switch (name) {
- case "size": this.size = newValue; break;
- }
- }
-
- mainDoc.registerElement(elemName, { prototype: proto });
-
- })(window, document);
- </script>
|