cotomy 2.0.4 → 2.0.5

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
@@ -290,11 +290,13 @@ const view = new CotomyViewRenderer(
290
290
  new CotomyElement(document.querySelector("#profile")!)
291
291
  );
292
292
 
293
- await view.applyAsync(apiResponse); // apiResponse is CotomyApiResponse from CotomyApi
293
+ await view.applyAsync(apiResponse); // CotomyApiResponse from CotomyApi, or a plain object payload
294
294
  // <span data-cotomy-bind="user.birthday" data-cotomy-bindtype="date" data-cotomy-format="MMM D, YYYY"></span>
295
295
  // → renders localized date text if the API payload contains user.birthday
296
296
  ```
297
297
 
298
+ `applyAsync` accepts either a `CotomyApiResponse` from `CotomyApi` or a plain object payload.
299
+
298
300
  #### Array binding
299
301
 
300
302
  - Both `CotomyViewRenderer.applyAsync` and `CotomyEntityFillApiForm.fillAsync` resolve array elements by index via the active `ICotomyBindNameGenerator` (dot style → `items[0].name`, bracket style → `items[0][name]`).
@@ -3495,10 +3495,15 @@ class CotomyViewRenderer {
3495
3495
  }
3496
3496
  }
3497
3497
  async applyAsync(respose) {
3498
- if (!respose.available) {
3499
- throw new Error("Response is not available.");
3498
+ if (respose instanceof CotomyApiResponse) {
3499
+ if (!respose.available) {
3500
+ throw new Error("Response is not available.");
3501
+ }
3502
+ await this.applyObjectAsync(await respose.objectAsync());
3503
+ }
3504
+ else {
3505
+ await this.applyObjectAsync(respose);
3500
3506
  }
3501
- await this.applyObjectAsync(await respose.objectAsync());
3502
3507
  return this;
3503
3508
  }
3504
3509
  }
@@ -4181,7 +4186,8 @@ class CotomyPageController {
4181
4186
  async initializeAsync() {
4182
4187
  this.initializeDateTimeElements();
4183
4188
  CotomyWindow.instance.pageshow(async (e) => {
4184
- if (e.persisted) {
4189
+ const navType = performance.getEntriesByType("navigation")[0]?.type;
4190
+ if (e.persisted || navType === "back_forward") {
4185
4191
  await this.restoreAsync();
4186
4192
  if (CotomyWindow.instance.reloading) {
4187
4193
  e.stopImmediatePropagation();