@aarongustafson/form-show-if 2.0.0 → 2.0.2

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
@@ -141,7 +141,7 @@ The "wrapper" mentioned below refers to the nearest mutual parent of the field &
141
141
 
142
142
  ## Demo
143
143
 
144
- [Live Demo](https://aarongustafson.github.io/form-show-if/demo.html) ([Source](./demo.html))
144
+ [Live Demo](https://aarongustafson.github.io/form-show-if/demo/index.html) ([Source](./demo/index.html))
145
145
 
146
146
  ## Browser Support
147
147
 
package/form-show-if.js CHANGED
@@ -140,7 +140,17 @@ export class FormShowIfElement extends HTMLElement {
140
140
  }
141
141
 
142
142
  static __getCurrentValue($field) {
143
- // Checkboxes are special
143
+ // Single checkbox
144
+ if ($field.type === 'checkbox' && !$field.length) {
145
+ // Only return the value if the checkbox is actually checked
146
+ if ($field.checked) {
147
+ // Return the value, defaulting to "on" if not explicitly set
148
+ return $field.value || 'on';
149
+ }
150
+ return '';
151
+ }
152
+
153
+ // Checkbox array (multiple checkboxes with same name)
144
154
  if ($field.length && $field[0].type && $field[0].type == 'checkbox') {
145
155
  let value = [];
146
156
  let length = $field.length;
@@ -153,6 +163,8 @@ export class FormShowIfElement extends HTMLElement {
153
163
  value.reverse();
154
164
  return value;
155
165
  }
166
+
167
+ // Radio buttons and other inputs
156
168
  return $field.value;
157
169
  }
158
170
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aarongustafson/form-show-if",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Web component that enables you to make one HTML form field show (or not) based on the value(s) of another field.",
5
5
  "keywords": [
6
6
  "html",