@mintjamsinc/ichigojs 0.1.62 → 0.1.64

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/ichigo.cjs CHANGED
@@ -7603,41 +7603,65 @@
7603
7603
  * Returns true when the target is a custom element and the binding should be
7604
7604
  * delivered as a property rather than an HTML attribute.
7605
7605
  *
7606
- * Two conditions trigger property delivery:
7606
+ * Three conditions trigger property delivery:
7607
7607
  * 1. The value is an object or array — serialising these to a string attribute
7608
7608
  * would lose type information.
7609
7609
  * 2. The element exposes a matching property accessor (e.g. a prop declared via
7610
7610
  * defineComponent), even when the value is a primitive.
7611
+ * 3. The element declares a matching prop in its static _props (case-insensitive
7612
+ * and kebab-case → camelCase tolerant), so primitive values reach the
7613
+ * reactive binding via the generated setter instead of being lost as a
7614
+ * plain HTML attribute that no attributeChangedCallback observes.
7611
7615
  */
7612
7616
  #isCustomElementProperty(element, name, value) {
7613
7617
  if (!element.tagName.includes('-')) {
7614
7618
  return false;
7615
7619
  }
7616
7620
  const isObjectOrArray = Array.isArray(value) || (typeof value === 'object' && value !== null);
7617
- return isObjectOrArray || name in element;
7621
+ if (isObjectOrArray || name in element) {
7622
+ return true;
7623
+ }
7624
+ return this.#findDeclaredProp(element, name) !== undefined;
7618
7625
  }
7619
7626
  /**
7620
7627
  * Resolves the actual property name on a custom element for a given
7621
7628
  * (lowercased) HTML attribute name. HTML attributes are always lowercase,
7622
7629
  * but custom element props are typically camelCase. This method checks the
7623
7630
  * element's declared _props (set by defineComponent) for a case-insensitive
7624
- * match, falling back to scanning the prototype's own property descriptors.
7631
+ * match against both the raw attribute name and its kebab-case → camelCase
7632
+ * conversion (so `user-name` resolves to `userName`), falling back to the
7633
+ * original name when no match is found.
7625
7634
  */
7626
7635
  #resolveCustomElementPropertyName(element, name) {
7627
7636
  // Fast path: exact match already exists
7628
7637
  if (name in element) {
7629
7638
  return name;
7630
7639
  }
7631
- // Check declared _props from defineComponent / IchigoElement
7640
+ return this.#findDeclaredProp(element, name) ?? name;
7641
+ }
7642
+ /**
7643
+ * Looks up a declared prop on a custom element constructor whose name matches
7644
+ * the given attribute name, treating the comparison as case-insensitive and
7645
+ * tolerant of kebab-case → camelCase conversion. Returns the canonical prop
7646
+ * name (as declared) when a match is found, or undefined otherwise.
7647
+ */
7648
+ #findDeclaredProp(element, name) {
7632
7649
  const props = element.constructor._props;
7633
- if (Array.isArray(props)) {
7634
- const lowerName = name.toLowerCase();
7635
- const match = props.find(p => p.toLowerCase() === lowerName);
7636
- if (match) {
7637
- return match;
7638
- }
7650
+ if (!Array.isArray(props)) {
7651
+ return undefined;
7639
7652
  }
7640
- return name;
7653
+ const lowerName = name.toLowerCase();
7654
+ const camelLower = this.#kebabToCamel(lowerName).toLowerCase();
7655
+ return props.find(p => {
7656
+ const lowerProp = p.toLowerCase();
7657
+ return lowerProp === lowerName || lowerProp === camelLower;
7658
+ });
7659
+ }
7660
+ /**
7661
+ * Converts kebab-case to camelCase (e.g. `user-name` → `userName`).
7662
+ */
7663
+ #kebabToCamel(str) {
7664
+ return str.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
7641
7665
  }
7642
7666
  /**
7643
7667
  * Checks if the attribute should be set as a DOM property.