haori 0.12.0 → 0.13.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/haori.es.js CHANGED
@@ -2290,7 +2290,7 @@ const V = class V extends w {
2290
2290
  }).finally(() => {
2291
2291
  this.skipChangeValue = !1;
2292
2292
  }));
2293
- } else return r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement || r instanceof HTMLSelectElement ? (this.value = e, this.skipChangeValue = !0, x.enqueue(() => {
2293
+ } else return r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement || r instanceof HTMLSelectElement ? (this.value = this.normalizeValueForElement(r, e), this.skipChangeValue = !0, x.enqueue(() => {
2294
2294
  r.value = e === null ? "" : String(e), t && ((r instanceof HTMLInputElement && this.INPUT_EVENT_TYPES.includes(r.type) || r instanceof HTMLTextAreaElement) && r.dispatchEvent(new Event("input", { bubbles: !0 })), r.dispatchEvent(new Event("change", { bubbles: !0 })));
2295
2295
  }).finally(() => {
2296
2296
  this.skipChangeValue = !1;
@@ -2315,6 +2315,26 @@ const V = class V extends w {
2315
2315
  clearValue() {
2316
2316
  this.value = null;
2317
2317
  }
2318
+ /**
2319
+ * 入力要素の種別に応じて値を正規化します。
2320
+ *
2321
+ * `type="number"` の input では、文字列の入力値・バインド値を数値へ変換します
2322
+ * (DTO が数値型を期待する場合に文字列で送られるのを防ぐため)。空文字・null・
2323
+ * 数値化できない値は `null` を返します。それ以外の要素では値をそのまま返します。
2324
+ *
2325
+ * @param element 対象の入力要素
2326
+ * @param value 正規化する値
2327
+ * @returns 正規化後の値(`type="number"` なら数値または null)
2328
+ */
2329
+ normalizeValueForElement(e, t) {
2330
+ if (e instanceof HTMLInputElement && e.type === "number") {
2331
+ if (t === null || t === "")
2332
+ return null;
2333
+ const r = typeof t == "number" ? t : Number(t);
2334
+ return Number.isNaN(r) ? null : r;
2335
+ }
2336
+ return t;
2337
+ }
2318
2338
  /**
2319
2339
  * 内部の値をDOMの値と同期します。
2320
2340
  * changeイベント時など、DOM値が変更された後に呼び出されます。
@@ -2332,7 +2352,7 @@ const V = class V extends w {
2332
2352
  t ? this.value = !1 : r === "false" ? this.value = !0 : this.value = null;
2333
2353
  }
2334
2354
  } else
2335
- this.value = e.value;
2355
+ this.value = this.normalizeValueForElement(e, e.value);
2336
2356
  else e instanceof HTMLTextAreaElement ? this.value = e.value : e instanceof HTMLSelectElement && (this.value = e.value);
2337
2357
  }
2338
2358
  /**
@@ -6124,7 +6144,7 @@ const O = class O {
6124
6144
  O._initialized = !1, O._mutationObservers = [];
6125
6145
  let _ = O;
6126
6146
  document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", _.init) : _.init();
6127
- const Ce = () => X.waitForRenders(), ke = "0.12.0";
6147
+ const Ce = () => X.waitForRenders(), ke = "0.13.0";
6128
6148
  export {
6129
6149
  P as Core,
6130
6150
  l as Env,