cotomy 0.4.2 → 0.4.3

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
@@ -66,6 +66,7 @@ The View layer provides thin wrappers around DOM elements and window events.
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
@@ -1182,17 +1182,32 @@ class CotomyElement {
1182
1182
  }
1183
1183
  return false;
1184
1184
  }
1185
- get enabled() {
1186
- return !(this.element.hasAttribute("disabled") && this.element.getAttribute("disabled") !== null);
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 enabled(value) {
1193
+ set disabled(value) {
1194
+ if ("disabled" in this.element) {
1195
+ this.element.disabled = value;
1196
+ return;
1197
+ }
1189
1198
  if (value) {
1190
- this.element.removeAttribute("disabled");
1199
+ this.attribute("disabled", "");
1191
1200
  }
1192
1201
  else {
1193
- this.element.setAttribute("disabled", "disabled");
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
  }