@optionfactory/fml 8.0.1 → 8.0.2

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/dist/ftl.mjs CHANGED
@@ -4378,25 +4378,38 @@ class UpgradeQueue {
4378
4378
  );
4379
4379
  });
4380
4380
  }
4381
+ #finished = new Map();
4381
4382
  enqueue(el) {
4382
4383
  if (this.#q.has(el)) {
4383
4384
  //already upgrading, can happen when disconnecting an element
4384
4385
  //while it's already queued for upgrade (e.g.: ful-form)
4385
4386
  return;
4386
4387
  }
4388
+ //settling waits on a signal that only ever resolves, so nothing here attaches a
4389
+ //rejection handler to the upgrade itself: a component that fails is still
4390
+ //reported the way it always was
4391
+ const { promise: finished, resolve: markFinished } = /** @type {PromiseWithResolvers<void>} */ (
4392
+ Promise.withResolvers()
4393
+ );
4387
4394
  const promise = Nodes.waitParsed(el)
4388
4395
  .then(() => el.upgrade())
4389
- .finally(() => this.#q.delete(el));
4396
+ .finally(() => {
4397
+ this.#q.delete(el);
4398
+ this.#finished.delete(el);
4399
+ markFinished();
4400
+ });
4390
4401
  this.#q.set(el, promise);
4402
+ this.#finished.set(el, finished);
4391
4403
  }
4392
4404
  /**
4393
- * Waits for every queued upgrade, including the ones enqueued while waiting:
4394
- * a component is only queued once its parent connects it, so a single pass would
4395
- * miss everything nested.
4405
+ * Waits for every queued upgrade to settle, including the ones enqueued while
4406
+ * waiting: a component is only queued once its parent connects it, so a single pass
4407
+ * would miss everything nested. A component that fails to upgrade does not hold the
4408
+ * others back, readiness means the queue drained rather than that everything worked.
4396
4409
  */
4397
4410
  async settle() {
4398
- while (this.#q.size !== 0) {
4399
- await Promise.all(Array.from(this.#q.values()));
4411
+ while (this.#finished.size !== 0) {
4412
+ await Promise.all(Array.from(this.#finished.values()));
4400
4413
  }
4401
4414
  }
4402
4415
  get entries() {
@@ -4688,6 +4701,19 @@ class ParsedElement extends HTMLElement {
4688
4701
  return;
4689
4702
  }
4690
4703
  Reflect.set(this, 'disabled', disabled);
4704
+ if (disabled) {
4705
+ this.#unclaimFormDisabled();
4706
+ }
4707
+ }
4708
+ //a disabled ancestor fieldset already matches the element through :disabled, and
4709
+ //an attribute of its own would keep the element disabled once the fieldset is
4710
+ //re-enabled, as formDisabledCallback(false) is only delivered on an actual state
4711
+ //change. a claim of its own made while already disabled by ancestry is safe: the
4712
+ //platform fires no callback for it, so it survives the fieldset being re-enabled
4713
+ #unclaimFormDisabled() {
4714
+ if (this.closest('fieldset:disabled')) {
4715
+ this.removeAttribute('disabled');
4716
+ }
4691
4717
  }
4692
4718
  async upgrade() {
4693
4719
  if (this.#parsed) {
@@ -4703,6 +4729,9 @@ class ParsedElement extends HTMLElement {
4703
4729
  );
4704
4730
  const disabled = this.#disabledBeforeParsed ?? false;
4705
4731
  await this.render({ slots, observed, disabled });
4732
+ if (disabled) {
4733
+ this.#unclaimFormDisabled();
4734
+ }
4706
4735
  }
4707
4736
  render(c) {}
4708
4737
  reflect(fn) {