|
68 | 68 | ;
|
69 | 69 | Object.setPrototypeOf(_CustomElement.prototype, HTMLElement.prototype);
|
70 | 70 | Object.setPrototypeOf(_CustomElement, HTMLElement);
|
71 |
| - var tmpl = document.createElement('template'); |
72 |
| - tmpl.innerHTML = '\n <style>\n .close-button {\n background: none;\n position: absolute;\n right: 0;\n top: 0;\n padding: 20px;\n border: 0;\n line-height: 1;\n }\n </style>\n <slot></slot>\n <button type="button" class="close-button" aria-label="Close dialog" data-close-dialog>╳</button>\n'; |
73 |
| - if (window.ShadyCSS) window.ShadyCSS.prepareTemplate(tmpl, 'details-dialog'); |
74 | 71 |
|
75 | 72 | var DetailsDialogElement = function (_CustomElement2) {
|
76 | 73 | _inherits(DetailsDialogElement, _CustomElement2);
|
|
80 | 77 |
|
81 | 78 | var _this = _possibleConstructorReturn(this, (DetailsDialogElement.__proto__ || Object.getPrototypeOf(DetailsDialogElement)).call(this));
|
82 | 79 |
|
83 |
| - if (window.ShadyCSS) window.ShadyCSS.styleElement(_this); |
84 |
| - _this.attachShadow({ mode: 'open' }); |
85 |
| - _this.shadowRoot.appendChild(document.importNode(tmpl.content, true)); |
86 |
| - |
| 80 | + _this._createCloseButton(); |
87 | 81 | _this.details = _this.parentElement;
|
88 |
| - _this.closeButton = _this.shadowRoot.querySelector('.close-button'); |
89 | 82 | _this.setAttribute('role', 'dialog');
|
90 | 83 |
|
91 | 84 | var keyDownHelpers = _this._keyDownHelpers.bind(_this);
|
|
95 | 88 | if (this.details.open) {
|
96 | 89 | this._autofocus();
|
97 | 90 | this.details.addEventListener('keydown', keyDownHelpers);
|
98 |
| - this.shadowRoot.addEventListener('click', captureDismissal); |
| 91 | + this.addEventListener('click', captureDismissal); |
99 | 92 | } else {
|
| 93 | + var _iteratorNormalCompletion = true; |
| 94 | + var _didIteratorError = false; |
| 95 | + var _iteratorError = undefined; |
| 96 | + |
| 97 | + try { |
| 98 | + for (var _iterator = this.querySelectorAll('form')[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
| 99 | + var form = _step.value; |
| 100 | + |
| 101 | + form.reset(); |
| 102 | + } |
| 103 | + } catch (err) { |
| 104 | + _didIteratorError = true; |
| 105 | + _iteratorError = err; |
| 106 | + } finally { |
| 107 | + try { |
| 108 | + if (!_iteratorNormalCompletion && _iterator.return) { |
| 109 | + _iterator.return(); |
| 110 | + } |
| 111 | + } finally { |
| 112 | + if (_didIteratorError) { |
| 113 | + throw _iteratorError; |
| 114 | + } |
| 115 | + } |
| 116 | + } |
| 117 | + |
100 | 118 | var summary = this.details.querySelector('summary');
|
101 | 119 | summary.focus();
|
102 | 120 |
|
103 | 121 | this.details.removeEventListener('keydown', keyDownHelpers);
|
104 |
| - this.shadowRoot.removeEventListener('click', captureDismissal); |
| 122 | + this.removeEventListener('click', captureDismissal); |
105 | 123 | }
|
106 | 124 | }.bind(_this), { capture: true });
|
107 | 125 | return _this;
|
108 | 126 | }
|
109 | 127 |
|
110 | 128 | _createClass(DetailsDialogElement, [{
|
| 129 | + key: '_createCloseButton', |
| 130 | + value: function _createCloseButton() { |
| 131 | + this.closeButton = document.createElement('button'); |
| 132 | + this.closeButton.innerHTML = '╳'; |
| 133 | + this.closeButton.classList.add('dd-close-button'); |
| 134 | + this.closeButton.setAttribute('type', 'button'); |
| 135 | + this.closeButton.setAttribute('aria-label', 'Close dialog'); |
| 136 | + this.closeButton.setAttribute('data-close-dialog', true); |
| 137 | + this.appendChild(this.closeButton); |
| 138 | + } |
| 139 | + }, { |
111 | 140 | key: '_autofocus',
|
112 | 141 | value: function _autofocus() {
|
113 | 142 | var autofocus = this.querySelector('[autofocus]');
|
|
0 commit comments