cotomy 0.3.11 → 0.3.13
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 +1 -1
- package/dist/browser/cotomy.js +8 -3
- package/dist/browser/cotomy.js.map +1 -1
- package/dist/browser/cotomy.min.js +1 -1
- package/dist/browser/cotomy.min.js.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/view.js +8 -3
- package/dist/esm/view.js.map +1 -1
- package/dist/types/view.d.ts +2 -1
- package/package.json +1 -1
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
|
|
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
|
package/dist/browser/cotomy.js
CHANGED
|
@@ -893,7 +893,7 @@ class CotomyElement {
|
|
|
893
893
|
return new ctor(element);
|
|
894
894
|
}
|
|
895
895
|
static last(selector, type) {
|
|
896
|
-
const elements =
|
|
896
|
+
const elements = CotomyElement.find(selector, type);
|
|
897
897
|
return elements.pop();
|
|
898
898
|
}
|
|
899
899
|
static find(selector, type) {
|
|
@@ -905,7 +905,9 @@ class CotomyElement {
|
|
|
905
905
|
return document.querySelector(selector) !== null;
|
|
906
906
|
}
|
|
907
907
|
static byId(id, type) {
|
|
908
|
-
|
|
908
|
+
const element = document.getElementById(id);
|
|
909
|
+
const ctor = (type ?? CotomyElement);
|
|
910
|
+
return !element ? undefined : new ctor(element);
|
|
909
911
|
}
|
|
910
912
|
static containsById(id) {
|
|
911
913
|
return document.getElementById(id) !== null;
|
|
@@ -942,7 +944,10 @@ class CotomyElement {
|
|
|
942
944
|
}
|
|
943
945
|
}
|
|
944
946
|
}
|
|
945
|
-
|
|
947
|
+
this.setInstanceId();
|
|
948
|
+
}
|
|
949
|
+
setInstanceId() {
|
|
950
|
+
if (!this.hasAttribute("data-cotomy-instance")) {
|
|
946
951
|
this.attribute("data-cotomy-instance", cuid_default()());
|
|
947
952
|
this.removed(() => {
|
|
948
953
|
this._element = CotomyElement.createHTMLElement(`<div data-cotomy-invalidated style="display: none;"></div>`);
|