snice 3.10.0 → 3.10.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/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * snice v3.9.0
2
+ * snice v3.10.1
3
3
  * Imperative TypeScript framework for building vanilla web components with decorators, differential rendering, routing, and controllers. No virtual DOM, no build complexity.
4
4
  * (c) 2024
5
5
  * Released under the MIT License.
@@ -1490,10 +1490,12 @@ function matchesKeyboardFilter(event, filter) {
1490
1490
  * ConditionalIfPart handles <if> conditional rendering
1491
1491
  * Removes/inserts DOM nodes based on condition
1492
1492
  */
1493
+ // Sentinel value to distinguish "not yet set" from undefined
1494
+ const NOT_SET = Symbol('not-set');
1493
1495
  class ConditionalIfPart extends Part {
1494
1496
  constructor(ifElement) {
1495
1497
  super();
1496
- this.value = undefined;
1498
+ this.value = NOT_SET;
1497
1499
  this.fragment = null;
1498
1500
  this.ifElement = ifElement;
1499
1501
  this.ifElement.style.display = 'contents';
@@ -1535,7 +1537,7 @@ class ConditionalIfPart extends Part {
1535
1537
  class ConditionalCasePart extends Part {
1536
1538
  constructor(caseElement) {
1537
1539
  super();
1538
- this.value = undefined;
1540
+ this.value = NOT_SET;
1539
1541
  this.childrenMap = new Map();
1540
1542
  this.fragments = new Map();
1541
1543
  this.defaultChild = null;
@@ -2576,6 +2578,10 @@ function valueToAttribute(value, propertyOptions, initialValue) {
2576
2578
  // Use explicit type or detect from initial value
2577
2579
  const typeToUse = propertyOptions.type || detectType(initialValue);
2578
2580
  switch (typeToUse) {
2581
+ case Boolean:
2582
+ // For boolean attributes, return "true" when true
2583
+ // (false is already handled above - returns null to remove attribute)
2584
+ return 'true';
2579
2585
  case Date:
2580
2586
  return value instanceof Date ? value.toISOString() : String(value);
2581
2587
  case BigInt:
@@ -2998,6 +3004,10 @@ function applyElementFunctionality(constructor) {
2998
3004
  this[EXPLICITLY_SET_PROPERTIES] = new Set();
2999
3005
  }
3000
3006
  this[EXPLICITLY_SET_PROPERTIES].add(propName);
3007
+ // For boolean attributes, normalize to "true" if they're empty
3008
+ if (propOptions.type === Boolean && attrValue === '') {
3009
+ this.setAttribute(attributeName, 'true');
3010
+ }
3001
3011
  this[propName] = parseAttributeValue(attrValue, propOptions);
3002
3012
  }
3003
3013
  }