cotomy 2.0.2 → 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,7 +271,7 @@ 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, return lowercase keys such as `date` or `customtype`.
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
275
 
276
276
  ### UTC Renderer
277
277
 
@@ -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
3243
  const type = element.attribute("data-cotomy-bindtype")?.trim().toLowerCase();
3243
- if (type && this.renderers[type]) {
3244
- this.renderers[type](element, value);
3245
- }
3246
- else {
3247
- element.text = String(value ?? "");
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) {