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