cotomy 0.3.11 → 0.3.12

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
@@ -48,7 +48,7 @@ The View layer provides thin wrappers around DOM elements and window events.
48
48
  - `CotomyElement.byId(id, type?)`
49
49
  - `CotomyElement.empty(type?)` — Creates a hidden placeholder element
50
50
  - Identity & matching
51
- - `instanceId: string | null | undefined` — Public getter backed by `data-cotomy-instance`
51
+ - `instanceId: string` — Always returns the element's `data-cotomy-instance` (generated when missing, respects existing values)
52
52
  - `id: string | null | undefined`
53
53
  - `generateId(prefix = "__cotomy_elem__"): this`
54
54
  - `is(selector: string): boolean` — Parent-aware matching helper
@@ -942,7 +942,10 @@ class CotomyElement {
942
942
  }
943
943
  }
944
944
  }
945
- if (!this.instanceId) {
945
+ this.setInstanceId();
946
+ }
947
+ setInstanceId() {
948
+ if (!this.hasAttribute("data-cotomy-instance")) {
946
949
  this.attribute("data-cotomy-instance", cuid_default()());
947
950
  this.removed(() => {
948
951
  this._element = CotomyElement.createHTMLElement(`<div data-cotomy-invalidated style="display: none;"></div>`);