@optionfactory/fml 9.0.0-rc20 → 9.0.0-rc21

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/fml.iife.js CHANGED
@@ -7596,6 +7596,17 @@ var fml = (function (exports) {
7596
7596
  }
7597
7597
  }
7598
7598
 
7599
+ /**
7600
+ * The form owning an element: its `form` property, or `internals.form` for a
7601
+ * form-associated element that has none. An element no form can own answers
7602
+ * undefined, its internals, which every ParsedElement holds, throwing on a
7603
+ * read of `form` unless the element is form-associated.
7604
+ * @param {any} el
7605
+ * @returns {HTMLFormElement|null|undefined}
7606
+ */
7607
+ const ownerOf = (el) =>
7608
+ el.form !== undefined ? el.form : el.constructor?.formAssociated ? el.internals?.form : undefined;
7609
+
7599
7610
  /**
7600
7611
  * Moves its children into a native `<form novalidate>`, extracts their values
7601
7612
  * on submit and hands them to a loader, reporting problems through `errors`.
@@ -7661,7 +7672,7 @@ var fml = (function (exports) {
7661
7672
  );
7662
7673
  if (this.declared('clear-invalid-on-change')) {
7663
7674
  this.addEventListener('change', (/** @type any */ evt) => {
7664
- if ((evt.target.form ?? evt.target.internals?.form) !== this.form) {
7675
+ if (ownerOf(evt.target) !== this.form) {
7665
7676
  return;
7666
7677
  }
7667
7678
  evt.target.setCustomValidity?.('');
@@ -7892,7 +7903,7 @@ var fml = (function (exports) {
7892
7903
  */
7893
7904
  #nameOf(target) {
7894
7905
  for (let el = target; el && el !== this; el = el.parentElement) {
7895
- if ((el.form ?? el.internals?.form) === this.form && el.hasAttribute('name')) {
7906
+ if (ownerOf(el) === this.form && el.hasAttribute('name')) {
7896
7907
  return el.getAttribute('name');
7897
7908
  }
7898
7909
  }