cotomy 0.4.2 → 0.4.4
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 +3 -2
- package/dist/browser/cotomy.js +21 -6
- 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 +21 -6
- package/dist/esm/view.js.map +1 -1
- package/dist/types/view.d.ts +4 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -57,15 +57,16 @@ The View layer provides thin wrappers around DOM elements and window events.
|
|
|
57
57
|
- `is(selector: string): boolean` — Parent-aware matching helper
|
|
58
58
|
- `empty: boolean` — True for tags that cannot have children or have no content
|
|
59
59
|
- Attributes, classes, styles
|
|
60
|
-
- `attribute(name)` / `attribute(name, value | null): this`
|
|
60
|
+
- `attribute(name)` / `attribute(name, value | null | undefined): this` — `null`/`undefined` removes the attribute
|
|
61
61
|
- `hasAttribute(name): boolean`
|
|
62
62
|
- `addClass(name): this` / `removeClass(name): this` / `toggleClass(name, force?): this` / `hasClass(name): boolean`
|
|
63
|
-
- `style(name)` / `style(name, value | null): this`
|
|
63
|
+
- `style(name)` / `style(name, value | null | undefined): this` — `null`/`undefined` removes the style
|
|
64
64
|
- Content & value
|
|
65
65
|
- `text: string` (get/set)
|
|
66
66
|
- `html: string` (get/set)
|
|
67
67
|
- `value: string` — Works for inputs; falls back to `data-cotomy-value` otherwise
|
|
68
68
|
- `readonly: boolean` (get/set) — Uses native property if available, otherwise attribute
|
|
69
|
+
- `disabled: boolean` (get/set) — Uses native property if available (respects `fieldset[disabled]`), otherwise attribute
|
|
69
70
|
- `enabled: boolean` (get/set) — Toggles `disabled` attribute
|
|
70
71
|
- `setFocus(): void`
|
|
71
72
|
- Tree traversal & manipulation
|
package/dist/browser/cotomy.js
CHANGED
|
@@ -1182,17 +1182,32 @@ class CotomyElement {
|
|
|
1182
1182
|
}
|
|
1183
1183
|
return false;
|
|
1184
1184
|
}
|
|
1185
|
-
get
|
|
1186
|
-
|
|
1185
|
+
get disabled() {
|
|
1186
|
+
if ("disabled" in this.element) {
|
|
1187
|
+
if (this.match(":disabled"))
|
|
1188
|
+
return true;
|
|
1189
|
+
return this.element.disabled;
|
|
1190
|
+
}
|
|
1191
|
+
return this.element.hasAttribute("disabled");
|
|
1187
1192
|
}
|
|
1188
|
-
set
|
|
1193
|
+
set disabled(value) {
|
|
1194
|
+
if ("disabled" in this.element) {
|
|
1195
|
+
this.element.disabled = value;
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1189
1198
|
if (value) {
|
|
1190
|
-
this.
|
|
1199
|
+
this.attribute("disabled", "");
|
|
1191
1200
|
}
|
|
1192
1201
|
else {
|
|
1193
|
-
this.
|
|
1202
|
+
this.attribute("disabled", null);
|
|
1194
1203
|
}
|
|
1195
1204
|
}
|
|
1205
|
+
get enabled() {
|
|
1206
|
+
return !this.disabled;
|
|
1207
|
+
}
|
|
1208
|
+
set enabled(value) {
|
|
1209
|
+
this.disabled = !value;
|
|
1210
|
+
}
|
|
1196
1211
|
get invalidated() {
|
|
1197
1212
|
return this.element.hasAttribute("data-cotomy-invalidated");
|
|
1198
1213
|
}
|
|
@@ -1477,7 +1492,7 @@ class CotomyElement {
|
|
|
1477
1492
|
if (arguments.length === 1) {
|
|
1478
1493
|
return this.element.hasAttribute(name) ? this.element.getAttribute(name) : undefined;
|
|
1479
1494
|
}
|
|
1480
|
-
else if (value
|
|
1495
|
+
else if (value == null) {
|
|
1481
1496
|
this.element.removeAttribute(name);
|
|
1482
1497
|
return this;
|
|
1483
1498
|
}
|