@wcstack/camera 4.5.0 → 4.6.0

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/index.esm.js CHANGED
@@ -795,6 +795,21 @@ function hasAccessorOnPrototype(target, name) {
795
795
  }
796
796
  return false;
797
797
  }
798
+ // 属性になってしまったオブジェクトの入力(`files="[object File]"`)を、要素ごとに 1 回だけ言う。
799
+ // React 19 は定義前の要素にプロパティが無いのでオブジェクトを属性に書き、Vue の `.attr` も
800
+ // 書く。要素はその入力をプロパティでしか読まないので、何も受け取らず、何も言わなかった
801
+ // (docs/seam-apps.md、fw-inventory)。
802
+ const toldObjectAttribute = new WeakSet();
803
+ function warnObjectAttribute(element, name, value) {
804
+ if (toldObjectAttribute.has(element))
805
+ return;
806
+ toldObjectAttribute.add(element);
807
+ const tag = element.localName ?? "element";
808
+ console.warn(`[wcs/input-as-attribute] <${tag}> has the attribute ${name}="${value}": an object was written as an ` +
809
+ `attribute, so the element did not receive it. A framework does that when the property is set before the ` +
810
+ `element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, ` +
811
+ `or assign the property through a ref (Vue: .prop). (Said once per element.)`, element);
812
+ }
798
813
  /**
799
814
  * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で
800
815
  * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。
@@ -802,14 +817,19 @@ function hasAccessorOnPrototype(target, name) {
802
817
  * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。
803
818
  * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。
804
819
  * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。
820
+ * - 値が `[object …]` の属性(属性に書かれてしまったオブジェクトの入力)は、要素ごとに 1 回警告する。
805
821
  */
806
822
  function upgradeProperties(element) {
807
823
  const declaration = element.constructor?.wcBindable;
808
824
  const inputs = declaration?.inputs;
809
825
  if (inputs === undefined)
810
826
  return;
827
+ const getAttribute = element.getAttribute;
811
828
  for (const input of inputs) {
812
829
  const name = input.name;
830
+ const attribute = typeof getAttribute === "function" ? getAttribute.call(element, name.toLowerCase()) : null;
831
+ if (attribute !== null && attribute.startsWith("[object "))
832
+ warnObjectAttribute(element, name, attribute);
813
833
  if (!Object.prototype.hasOwnProperty.call(element, name))
814
834
  continue;
815
835
  if (!hasAccessorOnPrototype(element, name))