No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

card-vspace.html 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <template id="card-vspace">
  2. <style id="style">
  3. :host {
  4. width: 100%;
  5. flex: 0 1 1em;
  6. }
  7. </style>
  8. </template>
  9. <script>
  10. (function(window, document) {
  11. var elemName = 'card-vspace';
  12. var mainDoc = document;
  13. var importDoc = document.currentScript.ownerDocument;
  14. var proto = Object.create(HTMLDivElement.prototype);
  15. Object.defineProperty(proto, "size", {
  16. get: function() {
  17. return "";
  18. },
  19. set: function (value) {
  20. this.setAttribute('size', value);
  21. var root = this.shadowRoot;
  22. var style = root.getElementById("style");
  23. style.innerHTML = ":host{width:100%;flex: 0 1 "+value+"}"
  24. }
  25. });
  26. proto.createdCallback = function () {
  27. var template = importDoc.getElementById(elemName);
  28. var clone = mainDoc.importNode(template.content, true);
  29. var root = this.createShadowRoot();
  30. root.appendChild(clone);
  31. this.size = this.getAttribute('size') || "1em";
  32. }
  33. proto.attributeChangedCallback = function (name, oldValue, newValue) {
  34. switch (name) {
  35. case "size": this.size = newValue; break;
  36. }
  37. }
  38. mainDoc.registerElement(elemName, { prototype: proto });
  39. })(window, document);
  40. </script>