cotomy 2.0.1 → 2.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/README.md CHANGED
@@ -271,6 +271,8 @@ The Form layer builds on `CotomyElement` for common form flows.
271
271
  - `utc` — Treats the value as UTC (or appends `Z` when missing) and formats with `data-cotomy-format` (default `YYYY/MM/DD HH:mm`). By default it renders in local time; set `data-cotomy-timezone` (element or ancestor) to render in a specific IANA timezone.
272
272
  - `date` — Renders local dates with `data-cotomy-format` (default `YYYY/MM/DD`) when the input is a valid `Date` value. By default it renders in local time; set `data-cotomy-timezone` (element or ancestor) to render in a specific IANA timezone.
273
273
 
274
+ `data-cotomy-bindtype` values are matched case-insensitively and surrounding whitespace is ignored. Custom renderers registered through `renderer(type, callback)` are stored with lowercase keys. If you override the protected `renderers` map directly, keys are also matched case-insensitively.
275
+
274
276
  ### UTC Renderer
275
277
 
276
278
  - Supports ISO 8601 offsets (`+09:00`, `-05:00`)
@@ -3154,7 +3154,7 @@ class CotomyViewRenderer {
3154
3154
  this._initialized = false;
3155
3155
  }
3156
3156
  renderer(type, callback) {
3157
- this._renderers[type] = callback;
3157
+ this._renderers[type.trim().toLowerCase()] = callback;
3158
3158
  return this;
3159
3159
  }
3160
3160
  get renderers() {
@@ -3235,17 +3235,20 @@ class CotomyViewRenderer {
3235
3235
  return this;
3236
3236
  }
3237
3237
  bindPrimitiveValue(propertyName, value) {
3238
+ let renderers;
3238
3239
  this.element.find(`[data-cotomy-bind="${propertyName}" i]`).forEach(element => {
3239
3240
  if (CotomyDebugSettings.isEnabled(CotomyDebugFeature.Bind)) {
3240
3241
  console.debug(`Binding data to element [data-cotomy-bind="${propertyName}"]:`, value);
3241
3242
  }
3242
- const type = element.attribute("data-cotomy-bindtype")?.toLowerCase();
3243
- if (type && this.renderers[type]) {
3244
- this.renderers[type](element, value);
3245
- }
3246
- else {
3247
- element.text = String(value ?? "");
3243
+ const type = element.attribute("data-cotomy-bindtype")?.trim().toLowerCase();
3244
+ if (type) {
3245
+ renderers ?? (renderers = Object.fromEntries(Object.entries(this.renderers).map(([key, renderer]) => [key.toLowerCase(), renderer])));
3246
+ if (renderers[type]) {
3247
+ renderers[type](element, value);
3248
+ return;
3249
+ }
3248
3250
  }
3251
+ element.text = String(value ?? "");
3249
3252
  });
3250
3253
  }
3251
3254
  async applyArrayAsync(values, propertyName) {