cotomy 0.1.72 → 0.1.73
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/dist/browser/cotomy.js +41 -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 +41 -3
- package/dist/esm/view.js.map +1 -1
- package/dist/types/view.d.ts +4 -0
- package/package.json +1 -1
package/dist/browser/cotomy.js
CHANGED
|
@@ -804,12 +804,12 @@ class HandlerRegistory {
|
|
|
804
804
|
}
|
|
805
805
|
}
|
|
806
806
|
class EventRegistry {
|
|
807
|
-
static get instance() {
|
|
808
|
-
return this._instance ?? (this._instance = new EventRegistry());
|
|
809
|
-
}
|
|
810
807
|
constructor() {
|
|
811
808
|
this._registry = new Map();
|
|
812
809
|
}
|
|
810
|
+
static get instance() {
|
|
811
|
+
return this._instance ?? (this._instance = new EventRegistry());
|
|
812
|
+
}
|
|
813
813
|
map(target) {
|
|
814
814
|
const scopeId = target.scopeId;
|
|
815
815
|
let registry = this._registry.get(scopeId);
|
|
@@ -1023,6 +1023,14 @@ class CotomyElement {
|
|
|
1023
1023
|
}
|
|
1024
1024
|
return true;
|
|
1025
1025
|
}
|
|
1026
|
+
match(selector) {
|
|
1027
|
+
try {
|
|
1028
|
+
return this.element.matches(selector);
|
|
1029
|
+
}
|
|
1030
|
+
catch {
|
|
1031
|
+
return false;
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1026
1034
|
get empty() {
|
|
1027
1035
|
const nonEmptyTags = new Set([
|
|
1028
1036
|
"input", "select", "textarea", "img", "video", "audio", "br", "hr",
|
|
@@ -1339,6 +1347,36 @@ class CotomyElement {
|
|
|
1339
1347
|
return undefined;
|
|
1340
1348
|
}
|
|
1341
1349
|
}
|
|
1350
|
+
previousSibling(selector = "*", type) {
|
|
1351
|
+
const element = this.element.previousElementSibling;
|
|
1352
|
+
if (element !== null && element instanceof HTMLElement) {
|
|
1353
|
+
const ctor = (type ?? CotomyElement);
|
|
1354
|
+
const ce = new ctor(element);
|
|
1355
|
+
return ce.match(selector) ? ce : ce.previousSibling(selector, type);
|
|
1356
|
+
}
|
|
1357
|
+
else {
|
|
1358
|
+
return undefined;
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
nextSibling(selector = "*", type) {
|
|
1362
|
+
const element = this.element.nextElementSibling;
|
|
1363
|
+
if (element !== null && element instanceof HTMLElement) {
|
|
1364
|
+
const ctor = (type ?? CotomyElement);
|
|
1365
|
+
const ce = new ctor(element);
|
|
1366
|
+
return ce.match(selector) ? ce : ce.nextSibling(selector, type);
|
|
1367
|
+
}
|
|
1368
|
+
else {
|
|
1369
|
+
return undefined;
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
siblings(selector = "*", type) {
|
|
1373
|
+
const parent = this.element.parentElement;
|
|
1374
|
+
if (!parent)
|
|
1375
|
+
return [];
|
|
1376
|
+
const ctor = (type ?? CotomyElement);
|
|
1377
|
+
return Array.from(parent.children).filter((e) => e instanceof HTMLElement
|
|
1378
|
+
&& e !== this.element).map(e => new ctor(e)).filter(e => e.match(selector));
|
|
1379
|
+
}
|
|
1342
1380
|
find(selector, type) {
|
|
1343
1381
|
const elements = Array.from(this.element.querySelectorAll(selector));
|
|
1344
1382
|
return elements.map(e => new (type ?? CotomyElement)(e));
|