@wcstack/router 4.5.0 → 4.6.1

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
@@ -2639,6 +2639,21 @@ function hasAccessorOnPrototype(target, name) {
2639
2639
  }
2640
2640
  return false;
2641
2641
  }
2642
+ // 属性になってしまったオブジェクトの入力(`files="[object File]"`)を、要素ごとに 1 回だけ言う。
2643
+ // React 19 は定義前の要素にプロパティが無いのでオブジェクトを属性に書き、Vue の `.attr` も
2644
+ // 書く。要素はその入力をプロパティでしか読まないので、何も受け取らず、何も言わなかった
2645
+ // (docs/seam-apps.md、fw-inventory)。
2646
+ const toldObjectAttribute = new WeakSet();
2647
+ function warnObjectAttribute(element, name, value) {
2648
+ if (toldObjectAttribute.has(element))
2649
+ return;
2650
+ toldObjectAttribute.add(element);
2651
+ const tag = element.localName ?? "element";
2652
+ console.warn(`[wcs/input-as-attribute] <${tag}> has the attribute ${name}="${value}": an object was written as an ` +
2653
+ `attribute, so the element did not receive it. A framework does that when the property is set before the ` +
2654
+ `element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, ` +
2655
+ `or assign the property through a ref (Vue: .prop). (Said once per element.)`, element);
2656
+ }
2642
2657
  /**
2643
2658
  * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で
2644
2659
  * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。
@@ -2646,14 +2661,19 @@ function hasAccessorOnPrototype(target, name) {
2646
2661
  * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。
2647
2662
  * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。
2648
2663
  * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。
2664
+ * - 値が `[object …]` の属性(属性に書かれてしまったオブジェクトの入力)は、要素ごとに 1 回警告する。
2649
2665
  */
2650
2666
  function upgradeProperties(element) {
2651
2667
  const declaration = element.constructor?.wcBindable;
2652
2668
  const inputs = declaration?.inputs;
2653
2669
  if (inputs === undefined)
2654
2670
  return;
2671
+ const getAttribute = element.getAttribute;
2655
2672
  for (const input of inputs) {
2656
2673
  const name = input.name;
2674
+ const attribute = typeof getAttribute === "function" ? getAttribute.call(element, name.toLowerCase()) : null;
2675
+ if (attribute !== null && attribute.startsWith("[object "))
2676
+ warnObjectAttribute(element, name, attribute);
2657
2677
  if (!Object.prototype.hasOwnProperty.call(element, name))
2658
2678
  continue;
2659
2679
  if (!hasAccessorOnPrototype(element, name))
@@ -4427,7 +4447,7 @@ function bootstrapRouter(config, registry) {
4427
4447
  registerComponents(registry);
4428
4448
  }
4429
4449
 
4430
- var version = "4.5.0";
4450
+ var version = "4.6.1";
4431
4451
  var pkg = {
4432
4452
  version: version};
4433
4453