@optionfactory/fml 8.0.1 → 8.0.3

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() {
@@ -4681,14 +4694,30 @@ class ParsedElement extends HTMLElement {
4681
4694
  }
4682
4695
  this[attr] = this.unmarshal(attr, newValue);
4683
4696
  }
4684
- #disabledBeforeParsed = null;
4685
- formDisabledCallback(disabled) {
4686
- if (!this.#parsed) {
4687
- this.#disabledBeforeParsed = disabled;
4688
- return;
4689
- }
4690
- Reflect.set(this, 'disabled', disabled);
4691
- }
4697
+ /**
4698
+ * The disabled protocol follows the semantics of a native form control:
4699
+ *
4700
+ * - the `disabled` attribute on the host is the field's own claim, and nothing
4701
+ * but its author ever writes or removes it, in markup or through the property.
4702
+ * The framework never claims on the form's behalf, so there is nothing to
4703
+ * unclaim and nothing to lose: a field declared disabled inside a disabled
4704
+ * `<fieldset>` stays disabled when the fieldset comes back, exactly like a
4705
+ * native input keeps its attribute.
4706
+ * - the effective state is the claim OR a disabled fieldset ancestry, which the
4707
+ * platform maintains on its own: `:disabled` matches both, a disabled field is
4708
+ * left out of the submitted values, and the inner native controls are reached
4709
+ * by the ancestry as descendants of the fieldset.
4710
+ * - the `disabled` property reflects the claim only, like a native input's: a
4711
+ * field disabled by its ancestry reads `false` while `matches(':disabled')`
4712
+ * tells the effective state. Un-claiming inside a disabled fieldset cannot
4713
+ * enable the field.
4714
+ * - the inner controls mirror the claim and nothing else: the ancestry state is
4715
+ * never written anywhere, so it can never go stale, and the browser composes
4716
+ * the two on its own when it disables and re-enables a fieldset's descendants.
4717
+ *
4718
+ * Because of this, formDisabledCallback carries nothing the framework needs to
4719
+ * apply, and the protocol does not define it.
4720
+ */
4692
4721
  async upgrade() {
4693
4722
  if (this.#parsed) {
4694
4723
  return;
@@ -4701,8 +4730,9 @@ class ParsedElement extends HTMLElement {
4701
4730
  this.unmarshal(attribute, this.getAttribute(attribute)),
4702
4731
  ]),
4703
4732
  );
4704
- const disabled = this.#disabledBeforeParsed ?? false;
4705
- await this.render({ slots, observed, disabled });
4733
+ //the declared claim is what render receives: the ancestry state is not
4734
+ //passed around, it is already where it needs to be
4735
+ await this.render({ slots, observed, disabled: this.hasAttribute('disabled') });
4706
4736
  }
4707
4737
  render(c) {}
4708
4738
  reflect(fn) {