@pageboard/html 0.17.0 → 0.17.1
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.
- package/package.json +1 -1
- package/ui/form.js +19 -15
package/package.json
CHANGED
package/ui/form.js
CHANGED
|
@@ -315,7 +315,6 @@ class HTMLElementForm extends Page.create(HTMLFormElement) {
|
|
|
315
315
|
}
|
|
316
316
|
|
|
317
317
|
const scope = state.scope.copy();
|
|
318
|
-
scope.$request = form.read(true, e.submitter);
|
|
319
318
|
try {
|
|
320
319
|
const prelist = Array.from(form.elements)
|
|
321
320
|
.filter(node => Boolean(node.presubmit) && !node.disabled);
|
|
@@ -323,10 +322,14 @@ class HTMLElementForm extends Page.create(HTMLFormElement) {
|
|
|
323
322
|
for (const node of prelist) {
|
|
324
323
|
await node.presubmit(state);
|
|
325
324
|
}
|
|
326
|
-
|
|
327
|
-
scope.$
|
|
328
|
-
|
|
329
|
-
|
|
325
|
+
} catch (err) {
|
|
326
|
+
scope.$response = err;
|
|
327
|
+
}
|
|
328
|
+
form.enable();
|
|
329
|
+
scope.$request = form.read(true, e.submitter);
|
|
330
|
+
form.disable();
|
|
331
|
+
form.classList.add('loading');
|
|
332
|
+
try {
|
|
330
333
|
scope.$response = await state.fetch(
|
|
331
334
|
form.method,
|
|
332
335
|
e.submitter?.getAttribute('formaction') || form.action,
|
|
@@ -386,34 +389,35 @@ Page.define(`element-form`, HTMLElementForm, 'form');
|
|
|
386
389
|
|
|
387
390
|
/* these methods must be available even on non-upgraded elements */
|
|
388
391
|
HTMLFormElement.prototype.enable = function () {
|
|
389
|
-
for (
|
|
390
|
-
|
|
392
|
+
for (const elem of this.elements) {
|
|
393
|
+
if (elem.matches('fieldset')) continue;
|
|
394
|
+
const fieldset = elem.closest('fieldset');
|
|
395
|
+
if (fieldset?.disabled) continue;
|
|
391
396
|
elem.disabled = false;
|
|
392
397
|
if (elem.hasAttribute('disabled')) elem.removeAttribute('disabled');
|
|
393
398
|
}
|
|
394
399
|
};
|
|
395
400
|
HTMLFormElement.prototype.disable = function () {
|
|
396
|
-
for (
|
|
397
|
-
|
|
401
|
+
for (const elem of this.elements) {
|
|
402
|
+
if (elem.matches('fieldset')) continue;
|
|
398
403
|
elem.disabled = true;
|
|
399
404
|
}
|
|
400
405
|
};
|
|
401
406
|
|
|
402
407
|
HTMLSelectElement.prototype.fill = function (val) {
|
|
403
408
|
if (!Array.isArray(val)) val = [val];
|
|
404
|
-
for (
|
|
405
|
-
const opt = this.options[i];
|
|
409
|
+
for (const opt of this.options) {
|
|
406
410
|
opt.selected = val.includes(opt.value);
|
|
407
411
|
}
|
|
408
412
|
};
|
|
409
413
|
HTMLSelectElement.prototype.reset = function () {
|
|
410
|
-
for (
|
|
411
|
-
|
|
414
|
+
for (const opt of this.options) {
|
|
415
|
+
opt.selected = opt.defaultSelected;
|
|
412
416
|
}
|
|
413
417
|
};
|
|
414
418
|
HTMLSelectElement.prototype.save = function () {
|
|
415
|
-
for (
|
|
416
|
-
|
|
419
|
+
for (const opt of this.options) {
|
|
420
|
+
opt.defaultSelected = opt.selected;
|
|
417
421
|
}
|
|
418
422
|
};
|
|
419
423
|
|