@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.d.mts CHANGED
@@ -351,7 +351,30 @@ declare class ParsedElement extends HTMLElement {
351
351
  template(name?: string): any;
352
352
  connectedCallback(): void;
353
353
  attributeChangedCallback(attr: any, oldValue: any, newValue: any): void;
354
- formDisabledCallback(disabled: any): void;
354
+ /**
355
+ * The disabled protocol follows the semantics of a native form control:
356
+ *
357
+ * - the `disabled` attribute on the host is the field's own claim, and nothing
358
+ * but its author ever writes or removes it, in markup or through the property.
359
+ * The framework never claims on the form's behalf, so there is nothing to
360
+ * unclaim and nothing to lose: a field declared disabled inside a disabled
361
+ * `<fieldset>` stays disabled when the fieldset comes back, exactly like a
362
+ * native input keeps its attribute.
363
+ * - the effective state is the claim OR a disabled fieldset ancestry, which the
364
+ * platform maintains on its own: `:disabled` matches both, a disabled field is
365
+ * left out of the submitted values, and the inner native controls are reached
366
+ * by the ancestry as descendants of the fieldset.
367
+ * - the `disabled` property reflects the claim only, like a native input's: a
368
+ * field disabled by its ancestry reads `false` while `matches(':disabled')`
369
+ * tells the effective state. Un-claiming inside a disabled fieldset cannot
370
+ * enable the field.
371
+ * - the inner controls mirror the claim and nothing else: the ancestry state is
372
+ * never written anywhere, so it can never go stale, and the browser composes
373
+ * the two on its own when it disables and re-enables a fieldset's descendants.
374
+ *
375
+ * Because of this, formDisabledCallback carries nothing the framework needs to
376
+ * apply, and the protocol does not define it.
377
+ */
355
378
  upgrade(): Promise<void>;
356
379
  render(c: any): void;
357
380
  reflect(fn: any): void;
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() {
@@ -4684,14 +4697,30 @@ var ftl = (function (exports) {
4684
4697
  }
4685
4698
  this[attr] = this.unmarshal(attr, newValue);
4686
4699
  }
4687
- #disabledBeforeParsed = null;
4688
- formDisabledCallback(disabled) {
4689
- if (!this.#parsed) {
4690
- this.#disabledBeforeParsed = disabled;
4691
- return;
4692
- }
4693
- Reflect.set(this, 'disabled', disabled);
4694
- }
4700
+ /**
4701
+ * The disabled protocol follows the semantics of a native form control:
4702
+ *
4703
+ * - the `disabled` attribute on the host is the field's own claim, and nothing
4704
+ * but its author ever writes or removes it, in markup or through the property.
4705
+ * The framework never claims on the form's behalf, so there is nothing to
4706
+ * unclaim and nothing to lose: a field declared disabled inside a disabled
4707
+ * `<fieldset>` stays disabled when the fieldset comes back, exactly like a
4708
+ * native input keeps its attribute.
4709
+ * - the effective state is the claim OR a disabled fieldset ancestry, which the
4710
+ * platform maintains on its own: `:disabled` matches both, a disabled field is
4711
+ * left out of the submitted values, and the inner native controls are reached
4712
+ * by the ancestry as descendants of the fieldset.
4713
+ * - the `disabled` property reflects the claim only, like a native input's: a
4714
+ * field disabled by its ancestry reads `false` while `matches(':disabled')`
4715
+ * tells the effective state. Un-claiming inside a disabled fieldset cannot
4716
+ * enable the field.
4717
+ * - the inner controls mirror the claim and nothing else: the ancestry state is
4718
+ * never written anywhere, so it can never go stale, and the browser composes
4719
+ * the two on its own when it disables and re-enables a fieldset's descendants.
4720
+ *
4721
+ * Because of this, formDisabledCallback carries nothing the framework needs to
4722
+ * apply, and the protocol does not define it.
4723
+ */
4695
4724
  async upgrade() {
4696
4725
  if (this.#parsed) {
4697
4726
  return;
@@ -4704,8 +4733,9 @@ var ftl = (function (exports) {
4704
4733
  this.unmarshal(attribute, this.getAttribute(attribute)),
4705
4734
  ]),
4706
4735
  );
4707
- const disabled = this.#disabledBeforeParsed ?? false;
4708
- await this.render({ slots, observed, disabled });
4736
+ //the declared claim is what render receives: the ancestry state is not
4737
+ //passed around, it is already where it needs to be
4738
+ await this.render({ slots, observed, disabled: this.hasAttribute('disabled') });
4709
4739
  }
4710
4740
  render(c) {}
4711
4741
  reflect(fn) {