snice 3.10.1 → 3.10.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/dist/index.cjs +24 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +24 -17
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +24 -17
- package/dist/index.iife.js.map +1 -1
- package/dist/parts.d.ts +0 -4
- package/dist/symbols.cjs +1 -1
- package/dist/symbols.esm.js +1 -1
- package/dist/transitions.cjs +1 -1
- package/dist/transitions.esm.js +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* snice v3.10.
|
|
2
|
+
* snice v3.10.2
|
|
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 =
|
|
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 =
|
|
1540
|
+
this.value = NOT_SET;
|
|
1539
1541
|
this.childrenMap = new Map();
|
|
1540
1542
|
this.fragments = new Map();
|
|
1541
1543
|
this.defaultChild = null;
|
|
@@ -3010,17 +3012,19 @@ function applyElementFunctionality(constructor) {
|
|
|
3010
3012
|
}
|
|
3011
3013
|
}
|
|
3012
3014
|
}
|
|
3013
|
-
//
|
|
3014
|
-
//
|
|
3015
|
+
// Clear pre-init values for properties that have HTML attributes
|
|
3016
|
+
// This prevents field initializers from overwriting HTML attributes later
|
|
3015
3017
|
if (this[PRE_INIT_PROPERTY_VALUES]) {
|
|
3016
|
-
for (const [propName, propValue] of this[PRE_INIT_PROPERTY_VALUES]) {
|
|
3017
|
-
// Remove from map first so getter doesn't return it during setter call
|
|
3018
|
-
this[PRE_INIT_PROPERTY_VALUES].delete(propName);
|
|
3019
|
-
// Only apply pre-init value if NO HTML attribute exists
|
|
3020
|
-
// This prevents field initializers from overwriting HTML attributes
|
|
3018
|
+
for (const [propName, propValue] of Array.from(this[PRE_INIT_PROPERTY_VALUES].entries())) {
|
|
3021
3019
|
const propOptions = properties?.get(propName);
|
|
3022
3020
|
const attributeName = typeof propOptions?.attribute === 'string' ? propOptions.attribute : propName.toLowerCase();
|
|
3023
|
-
if (
|
|
3021
|
+
if (this.hasAttribute(attributeName)) {
|
|
3022
|
+
// Attribute exists - remove from PRE_INIT to prevent overwriting
|
|
3023
|
+
this[PRE_INIT_PROPERTY_VALUES].delete(propName);
|
|
3024
|
+
}
|
|
3025
|
+
else {
|
|
3026
|
+
// No attribute - apply the pre-init value
|
|
3027
|
+
this[PRE_INIT_PROPERTY_VALUES].delete(propName);
|
|
3024
3028
|
this[propName] = propValue;
|
|
3025
3029
|
}
|
|
3026
3030
|
}
|
|
@@ -3280,16 +3284,18 @@ function property(options) {
|
|
|
3280
3284
|
context.metadata[PROPERTIES].set(propertyKey, options || {});
|
|
3281
3285
|
// Return a field initializer function for new decorators
|
|
3282
3286
|
return function (initialValue) {
|
|
3287
|
+
// Ensure constructor[PROPERTIES] exists
|
|
3288
|
+
const constructor = this.constructor;
|
|
3289
|
+
if (!constructor[PROPERTIES]) {
|
|
3290
|
+
constructor[PROPERTIES] = new Map();
|
|
3291
|
+
}
|
|
3283
3292
|
// Detect type from initial value if not explicitly provided
|
|
3284
3293
|
const finalOptions = { ...options };
|
|
3285
3294
|
if (!finalOptions.type && initialValue !== undefined) {
|
|
3286
3295
|
finalOptions.type = detectType(initialValue);
|
|
3287
|
-
// Update the metadata with the detected type
|
|
3288
|
-
const constructor = this.constructor;
|
|
3289
|
-
if (constructor[PROPERTIES]) {
|
|
3290
|
-
constructor[PROPERTIES].set(propertyKey, finalOptions);
|
|
3291
|
-
}
|
|
3292
3296
|
}
|
|
3297
|
+
// Always store property options on constructor for runtime access
|
|
3298
|
+
constructor[PROPERTIES].set(propertyKey, finalOptions);
|
|
3293
3299
|
// Set up the property descriptor on first access
|
|
3294
3300
|
if (!Object.hasOwnProperty.call(this.constructor.prototype, propertyKey)) {
|
|
3295
3301
|
const descriptor = {
|
|
@@ -3318,8 +3324,9 @@ function property(options) {
|
|
|
3318
3324
|
// Get old value by calling the getter (which reads from attribute)
|
|
3319
3325
|
const oldValue = this[propertyKey];
|
|
3320
3326
|
// Check if value actually changed
|
|
3321
|
-
if (oldValue === newValue)
|
|
3327
|
+
if (oldValue === newValue) {
|
|
3322
3328
|
return;
|
|
3329
|
+
}
|
|
3323
3330
|
// Don't reflect to DOM until connectedCallback has started
|
|
3324
3331
|
// This prevents field initializers from overwriting HTML attributes
|
|
3325
3332
|
if (!this[PROPERTIES_INITIALIZED]) {
|