@schukai/monster 3.102.5 → 3.102.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,15 +12,15 @@
12
12
  * SPDX-License-Identifier: AGPL-3.0
13
13
  */
14
14
 
15
- import {extend} from "../data/extend.mjs";
16
- import {addAttributeToken} from "./attributes.mjs";
17
- import {ATTRIBUTE_ERRORMESSAGE} from "./constants.mjs";
18
- import {CustomElement, attributeObserverSymbol} from "./customelement.mjs";
19
- import {instanceSymbol} from "../constants.mjs";
20
- import {DeadMansSwitch} from "../util/deadmansswitch.mjs";
21
- import {addErrorAttribute} from "./error.mjs";
15
+ import { extend } from "../data/extend.mjs";
16
+ import { addAttributeToken } from "./attributes.mjs";
17
+ import { ATTRIBUTE_ERRORMESSAGE } from "./constants.mjs";
18
+ import { CustomElement, attributeObserverSymbol } from "./customelement.mjs";
19
+ import { instanceSymbol } from "../constants.mjs";
20
+ import { DeadMansSwitch } from "../util/deadmansswitch.mjs";
21
+ import { addErrorAttribute } from "./error.mjs";
22
22
 
23
- export {CustomControl};
23
+ export { CustomControl };
24
24
 
25
25
  /**
26
26
  * @private
@@ -53,286 +53,285 @@ const attachedInternalSymbol = Symbol("attachedInternal");
53
53
  * @since 1.14.0
54
54
  */
55
55
  class CustomControl extends CustomElement {
56
- /**
57
- * The constructor method of CustomControl, which is called when creating a new instance.
58
- * It checks whether the element supports `attachInternals()` and initializes an internal form-associated element
59
- * if supported. Additionally, it initializes a MutationObserver to watch for attribute changes.
60
- *
61
- * See the links below for more information:
62
- * {@link https://html.spec.whatwg.org/multipage/custom-elements.html#dom-customelementregistry-define|CustomElementRegistry.define()}
63
- * {@link https://html.spec.whatwg.org/multipage/custom-elements.html#dom-customelementregistry-get|CustomElementRegistry.get()}
64
- * and {@link https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals|ElementInternals}
65
- *
66
- * @inheritdoc
67
- * @throws {Error} the ElementInternals is not supported and a polyfill is necessary
68
- */
69
- constructor() {
70
- super();
71
-
72
- // check if element supports `attachInternals()`
73
- if (typeof this["attachInternals"] === "function") {
74
- this[attachedInternalSymbol] = this.attachInternals();
75
- } else {
76
- // `attachInternals()` is not supported, so a polyfill is necessary
77
- throw Error(
78
- "the ElementInternals is not supported and a polyfill is necessary",
79
- );
80
- }
81
-
82
- // watch for attribute value changes
83
- initValueAttributeObserver.call(this);
84
- }
85
-
86
- /**
87
- * This method is called by the `instanceof` operator.
88
- * @return {symbol}
89
- * @since 2.1.0
90
- */
91
- static get [instanceSymbol]() {
92
- return Symbol.for("@schukai/monster/dom/custom-control@@instance");
93
- }
94
-
95
- /**
96
- * This method determines which attributes are to be monitored by `attributeChangedCallback()`.
97
- *
98
- * @return {string[]}
99
- * @since 1.15.0
100
- */
101
- static get observedAttributes() {
102
- return super.observedAttributes;
103
- }
104
-
105
- /**
106
- * Adding a static `formAssociated` property, with a true value, makes an autonomous custom element a form-associated custom element.
107
- *
108
- * @see [attachInternals()]{@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/attachInternals}
109
- * @see [Custom Elements Face Example]{@link https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-face-example}
110
- * @return {boolean}
111
- */
112
- static formAssociated = true;
113
-
114
- /**
115
- * @inheritdoc
116
- **/
117
- get defaults() {
118
- return extend({}, super.defaults);
119
- }
120
-
121
- /**
122
- * Must be overridden by a derived class and return the value of the control.
123
- *
124
- * This is a method of [internal API](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals), which is a part of the web standard for custom elements.
125
- *
126
- * @throws {Error} the value getter must be overwritten by the derived class
127
- */
128
- get value() {
129
- throw Error("the value getter must be overwritten by the derived class");
130
- }
131
-
132
- /**
133
- * Must be overridden by a derived class and set the value of the control.
134
- *
135
- * This is a method of [internal API](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals), which is a part of the web standard for custom elements.
136
- *
137
- * @param {*} value The value to set.
138
- * @throws {Error} the value setter must be overwritten by the derived class
139
- */
140
- set value(value) {
141
- throw Error("the value setter must be overwritten by the derived class");
142
- }
143
-
144
- /**
145
- * This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
146
- *
147
- * @return {NodeList}
148
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/labels}
149
- * @throws {Error} the ElementInternals is not supported and a polyfill is necessary
150
- */
151
- get labels() {
152
- return getInternal.call(this)?.labels;
153
- }
154
-
155
- /**
156
- * This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
157
- *
158
- * @return {string|null}
159
- */
160
- get name() {
161
- return this.getAttribute("name");
162
- }
163
-
164
- /**
165
- * This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
166
- *
167
- * @return {string}
168
- */
169
- get type() {
170
- return this.constructor.getTag();
171
- }
172
-
173
- /**
174
- * This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
175
- *
176
- * @return {ValidityState}
177
- * @throws {Error} the ElementInternals is not supported and a polyfill is necessary
178
- * @see [ValidityState]{@link https://developer.mozilla.org/en-US/docs/Web/API/ValidityState}
179
- * @see [validity]{@link https://developer.mozilla.org/en-US/docs/Web/API/validity}
180
- */
181
- get validity() {
182
- return getInternal.call(this)?.validity;
183
- }
184
-
185
- /**
186
- * This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
187
- *
188
- * @return {string}
189
- * @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/validationMessage
190
- * @throws {Error} the ElementInternals is not supported and a polyfill is necessary
191
- */
192
- get validationMessage() {
193
- return getInternal.call(this)?.validationMessage;
194
- }
195
-
196
- /**
197
- * This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
198
- *
199
- * @return {boolean}
200
- * @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/willValidate
201
- * @throws {Error} the ElementInternals is not supported and a polyfill is necessary
202
- */
203
- get willValidate() {
204
- return getInternal.call(this)?.willValidate;
205
- }
206
-
207
- /**
208
- * This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
209
- *
210
- * @return {boolean}
211
- * @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/states
212
- * @throws {Error} the ElementInternals is not supported and a polyfill is necessary
213
- */
214
- get states() {
215
- return getInternal.call(this)?.states;
216
- }
217
-
218
- /**
219
- * This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
220
- *
221
- * @return {HTMLFontElement|null}
222
- * @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/form
223
- * @throws {Error} the ElementInternals is not supported and a polyfill is necessary
224
- */
225
- get form() {
226
- return getInternal.call(this)?.form;
227
- }
228
-
229
- /**
230
- * This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
231
- *
232
- * ```
233
- * // Use the control's name as the base name for submitted data
234
- * const n = this.getAttribute('name');
235
- * const entries = new FormData();
236
- * entries.append(n + '-first-name', this.firstName_);
237
- * entries.append(n + '-last-name', this.lastName_);
238
- * this.setFormValue(entries);
239
- * ```
240
- *
241
- * @param {File|string|FormData} value
242
- * @param {File|string|FormData} state
243
- * @return {undefined}
244
- * @throws {DOMException} NotSupportedError
245
- * @throws {Error} the ElementInternals is not supported and a polyfill is necessary
246
- * @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/setFormValue
247
- */
248
- setFormValue(value, state) {
249
- getInternal.call(this).setFormValue(value, state);
250
- }
251
-
252
- /**
253
- *
254
- * @param {object} flags
255
- * @param {string|undefined} message
256
- * @param {HTMLElement} anchor
257
- * @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/setValidity
258
- * @return {undefined}
259
- * @throws {DOMException} NotSupportedError
260
- * @throws {Error} the ElementInternals is not supported and a polyfill is necessary
261
- */
262
- setValidity(flags, message, anchor) {
263
- getInternal.call(this).setValidity(flags, message, anchor);
264
- }
265
-
266
- /**
267
- * This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
268
- *
269
- * @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/checkValidity
270
- * @return {boolean}
271
- * @throws {DOMException} NotSupportedError
272
- * @throws {Error} the ElementInternals is not supported and a polyfill is necessary
273
- */
274
- checkValidity() {
275
- return getInternal.call(this)?.checkValidity();
276
- }
277
-
278
- /**
279
- * This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
280
- *
281
- * @return {boolean}
282
- * @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/reportValidity
283
- * @throws {Error} the ElementInternals is not supported and a polyfill is necessary
284
- * @throws {DOMException} NotSupportedError
285
- */
286
- reportValidity() {
287
- return getInternal.call(this)?.reportValidity();
288
- }
289
-
290
- /**
291
- * Sets the `form` attribute of the custom control to the `id` of the passed form element.
292
- * If no form element is passed, removes the `form` attribute.
293
- *
294
- * @param {HTMLFormElement} form - The form element to associate with the control
295
- */
296
- formAssociatedCallback(form) {
297
- if (form) {
298
- if (form.id) {
299
- this.setAttribute("form", form.id);
300
- }
301
- } else {
302
- this.removeAttribute("form");
303
- }
304
- }
305
-
306
- /**
307
- * Sets or removes the `disabled` attribute of the custom control based on the passed value.
308
- *
309
- * @param {boolean} disabled - Whether or not the control should be disabled
310
- */
311
- formDisabledCallback(disabled) {
312
- if (disabled) {
313
- if (!this.hasAttribute("disabled")) {
314
- this.setAttribute("disabled", "");
315
- }
316
- } else {
317
- if (this.hasAttribute("disabled")) {
318
- this.removeAttribute("disabled");
319
- }
320
- }
321
- }
322
-
323
- /**
324
- * @param {string} state
325
- * @param {string} mode
326
- */
327
- formStateRestoreCallback(state, mode) {
328
- }
329
-
330
- /**
331
- *
332
- */
333
- formResetCallback() {
334
- this.value = "";
335
- }
56
+ /**
57
+ * The constructor method of CustomControl, which is called when creating a new instance.
58
+ * It checks whether the element supports `attachInternals()` and initializes an internal form-associated element
59
+ * if supported. Additionally, it initializes a MutationObserver to watch for attribute changes.
60
+ *
61
+ * See the links below for more information:
62
+ * {@link https://html.spec.whatwg.org/multipage/custom-elements.html#dom-customelementregistry-define|CustomElementRegistry.define()}
63
+ * {@link https://html.spec.whatwg.org/multipage/custom-elements.html#dom-customelementregistry-get|CustomElementRegistry.get()}
64
+ * and {@link https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals|ElementInternals}
65
+ *
66
+ * @inheritdoc
67
+ * @throws {Error} the ElementInternals is not supported and a polyfill is necessary
68
+ */
69
+ constructor() {
70
+ super();
71
+
72
+ // check if element supports `attachInternals()`
73
+ if (typeof this["attachInternals"] === "function") {
74
+ this[attachedInternalSymbol] = this.attachInternals();
75
+ } else {
76
+ // `attachInternals()` is not supported, so a polyfill is necessary
77
+ throw Error(
78
+ "the ElementInternals is not supported and a polyfill is necessary",
79
+ );
80
+ }
81
+
82
+ // watch for attribute value changes
83
+ initValueAttributeObserver.call(this);
84
+ }
85
+
86
+ /**
87
+ * This method is called by the `instanceof` operator.
88
+ * @return {symbol}
89
+ * @since 2.1.0
90
+ */
91
+ static get [instanceSymbol]() {
92
+ return Symbol.for("@schukai/monster/dom/custom-control@@instance");
93
+ }
94
+
95
+ /**
96
+ * This method determines which attributes are to be monitored by `attributeChangedCallback()`.
97
+ *
98
+ * @return {string[]}
99
+ * @since 1.15.0
100
+ */
101
+ static get observedAttributes() {
102
+ return super.observedAttributes;
103
+ }
104
+
105
+ /**
106
+ * Adding a static `formAssociated` property, with a true value, makes an autonomous custom element a form-associated custom element.
107
+ *
108
+ * @see [attachInternals()]{@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/attachInternals}
109
+ * @see [Custom Elements Face Example]{@link https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-face-example}
110
+ * @return {boolean}
111
+ */
112
+ static formAssociated = true;
113
+
114
+ /**
115
+ * @inheritdoc
116
+ **/
117
+ get defaults() {
118
+ return extend({}, super.defaults);
119
+ }
120
+
121
+ /**
122
+ * Must be overridden by a derived class and return the value of the control.
123
+ *
124
+ * This is a method of [internal API](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals), which is a part of the web standard for custom elements.
125
+ *
126
+ * @throws {Error} the value getter must be overwritten by the derived class
127
+ */
128
+ get value() {
129
+ throw Error("the value getter must be overwritten by the derived class");
130
+ }
131
+
132
+ /**
133
+ * Must be overridden by a derived class and set the value of the control.
134
+ *
135
+ * This is a method of [internal API](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals), which is a part of the web standard for custom elements.
136
+ *
137
+ * @param {*} value The value to set.
138
+ * @throws {Error} the value setter must be overwritten by the derived class
139
+ */
140
+ set value(value) {
141
+ throw Error("the value setter must be overwritten by the derived class");
142
+ }
143
+
144
+ /**
145
+ * This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
146
+ *
147
+ * @return {NodeList}
148
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/labels}
149
+ * @throws {Error} the ElementInternals is not supported and a polyfill is necessary
150
+ */
151
+ get labels() {
152
+ return getInternal.call(this)?.labels;
153
+ }
154
+
155
+ /**
156
+ * This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
157
+ *
158
+ * @return {string|null}
159
+ */
160
+ get name() {
161
+ return this.getAttribute("name");
162
+ }
163
+
164
+ /**
165
+ * This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
166
+ *
167
+ * @return {string}
168
+ */
169
+ get type() {
170
+ return this.constructor.getTag();
171
+ }
172
+
173
+ /**
174
+ * This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
175
+ *
176
+ * @return {ValidityState}
177
+ * @throws {Error} the ElementInternals is not supported and a polyfill is necessary
178
+ * @see [ValidityState]{@link https://developer.mozilla.org/en-US/docs/Web/API/ValidityState}
179
+ * @see [validity]{@link https://developer.mozilla.org/en-US/docs/Web/API/validity}
180
+ */
181
+ get validity() {
182
+ return getInternal.call(this)?.validity;
183
+ }
184
+
185
+ /**
186
+ * This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
187
+ *
188
+ * @return {string}
189
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/validationMessage
190
+ * @throws {Error} the ElementInternals is not supported and a polyfill is necessary
191
+ */
192
+ get validationMessage() {
193
+ return getInternal.call(this)?.validationMessage;
194
+ }
195
+
196
+ /**
197
+ * This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
198
+ *
199
+ * @return {boolean}
200
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/willValidate
201
+ * @throws {Error} the ElementInternals is not supported and a polyfill is necessary
202
+ */
203
+ get willValidate() {
204
+ return getInternal.call(this)?.willValidate;
205
+ }
206
+
207
+ /**
208
+ * This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
209
+ *
210
+ * @return {boolean}
211
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/states
212
+ * @throws {Error} the ElementInternals is not supported and a polyfill is necessary
213
+ */
214
+ get states() {
215
+ return getInternal.call(this)?.states;
216
+ }
217
+
218
+ /**
219
+ * This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
220
+ *
221
+ * @return {HTMLFontElement|null}
222
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/form
223
+ * @throws {Error} the ElementInternals is not supported and a polyfill is necessary
224
+ */
225
+ get form() {
226
+ return getInternal.call(this)?.form;
227
+ }
228
+
229
+ /**
230
+ * This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
231
+ *
232
+ * ```
233
+ * // Use the control's name as the base name for submitted data
234
+ * const n = this.getAttribute('name');
235
+ * const entries = new FormData();
236
+ * entries.append(n + '-first-name', this.firstName_);
237
+ * entries.append(n + '-last-name', this.lastName_);
238
+ * this.setFormValue(entries);
239
+ * ```
240
+ *
241
+ * @param {File|string|FormData} value
242
+ * @param {File|string|FormData} state
243
+ * @return {undefined}
244
+ * @throws {DOMException} NotSupportedError
245
+ * @throws {Error} the ElementInternals is not supported and a polyfill is necessary
246
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/setFormValue
247
+ */
248
+ setFormValue(value, state) {
249
+ getInternal.call(this).setFormValue(value, state);
250
+ }
251
+
252
+ /**
253
+ *
254
+ * @param {object} flags
255
+ * @param {string|undefined} message
256
+ * @param {HTMLElement} anchor
257
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/setValidity
258
+ * @return {undefined}
259
+ * @throws {DOMException} NotSupportedError
260
+ * @throws {Error} the ElementInternals is not supported and a polyfill is necessary
261
+ */
262
+ setValidity(flags, message, anchor) {
263
+ getInternal.call(this).setValidity(flags, message, anchor);
264
+ }
265
+
266
+ /**
267
+ * This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
268
+ *
269
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/checkValidity
270
+ * @return {boolean}
271
+ * @throws {DOMException} NotSupportedError
272
+ * @throws {Error} the ElementInternals is not supported and a polyfill is necessary
273
+ */
274
+ checkValidity() {
275
+ return getInternal.call(this)?.checkValidity();
276
+ }
277
+
278
+ /**
279
+ * This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
280
+ *
281
+ * @return {boolean}
282
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/reportValidity
283
+ * @throws {Error} the ElementInternals is not supported and a polyfill is necessary
284
+ * @throws {DOMException} NotSupportedError
285
+ */
286
+ reportValidity() {
287
+ return getInternal.call(this)?.reportValidity();
288
+ }
289
+
290
+ /**
291
+ * Sets the `form` attribute of the custom control to the `id` of the passed form element.
292
+ * If no form element is passed, removes the `form` attribute.
293
+ *
294
+ * @param {HTMLFormElement} form - The form element to associate with the control
295
+ */
296
+ formAssociatedCallback(form) {
297
+ if (form) {
298
+ if (form.id) {
299
+ this.setAttribute("form", form.id);
300
+ }
301
+ } else {
302
+ this.removeAttribute("form");
303
+ }
304
+ }
305
+
306
+ /**
307
+ * Sets or removes the `disabled` attribute of the custom control based on the passed value.
308
+ *
309
+ * @param {boolean} disabled - Whether or not the control should be disabled
310
+ */
311
+ formDisabledCallback(disabled) {
312
+ if (disabled) {
313
+ if (!this.hasAttribute("disabled")) {
314
+ this.setAttribute("disabled", "");
315
+ }
316
+ } else {
317
+ if (this.hasAttribute("disabled")) {
318
+ this.removeAttribute("disabled");
319
+ }
320
+ }
321
+ }
322
+
323
+ /**
324
+ * @param {string} state
325
+ * @param {string} mode
326
+ */
327
+ formStateRestoreCallback(state, mode) {}
328
+
329
+ /**
330
+ *
331
+ */
332
+ formResetCallback() {
333
+ this.value = "";
334
+ }
336
335
  }
337
336
 
338
337
  /**
@@ -342,13 +341,13 @@ class CustomControl extends CustomElement {
342
341
  * @this CustomControl
343
342
  */
344
343
  function getInternal() {
345
- if (!(attachedInternalSymbol in this)) {
346
- throw new Error(
347
- "ElementInternals is not supported and a polyfill is necessary",
348
- );
349
- }
344
+ if (!(attachedInternalSymbol in this)) {
345
+ throw new Error(
346
+ "ElementInternals is not supported and a polyfill is necessary",
347
+ );
348
+ }
350
349
 
351
- return this[attachedInternalSymbol];
350
+ return this[attachedInternalSymbol];
352
351
  }
353
352
 
354
353
  const debounceValueSymbol = Symbol("debounceValue");
@@ -362,31 +361,29 @@ const debounceValueSymbol = Symbol("debounceValue");
362
361
  * @this CustomControl
363
362
  */
364
363
  function initValueAttributeObserver() {
365
- const self = this;
366
- this[attributeObserverSymbol]["value"] = () => {
367
-
368
- if (self[debounceValueSymbol] instanceof DeadMansSwitch) {
369
- try {
370
- self[debounceValueSymbol].touch();
371
- return;
372
- } catch (e) {
373
- if (e.message !== "has already run") {
374
- throw e;
375
- }
376
- delete self[debounceValueSymbol];
377
- }
378
- }
379
-
380
- self[debounceValueSymbol] = new DeadMansSwitch(10, () => {
381
- const oldValue = self.getAttribute("value");
382
- const newValue = self.getOption("value");
383
-
384
- if (oldValue !== newValue) {
385
- setTimeout(() => {
386
- this.setOption("value", this.getAttribute("value"));
387
- },0);
388
-
389
- }
390
- });
391
- };
364
+ const self = this;
365
+ this[attributeObserverSymbol]["value"] = () => {
366
+ if (self[debounceValueSymbol] instanceof DeadMansSwitch) {
367
+ try {
368
+ self[debounceValueSymbol].touch();
369
+ return;
370
+ } catch (e) {
371
+ if (e.message !== "has already run") {
372
+ throw e;
373
+ }
374
+ delete self[debounceValueSymbol];
375
+ }
376
+ }
377
+
378
+ self[debounceValueSymbol] = new DeadMansSwitch(10, () => {
379
+ const oldValue = self.getAttribute("value");
380
+ const newValue = self.getOption("value");
381
+
382
+ if (oldValue !== newValue) {
383
+ setTimeout(() => {
384
+ this.setOption("value", this.getAttribute("value"));
385
+ }, 0);
386
+ }
387
+ });
388
+ };
392
389
  }