snice 3.9.0 → 3.10.0

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * snice v3.8.0
2
+ * snice v3.9.0
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.
@@ -990,7 +990,22 @@ var Snice = (function (exports) {
990
990
  const htmlParts = [];
991
991
  const attrNamesForParts = [];
992
992
  for (let i = 0; i < strings.length; i++) {
993
- const str = strings[i];
993
+ let str = strings[i];
994
+ // Encode slashes in attribute names to prevent browser from splitting them
995
+ // HTML doesn't allow / in attribute names - browser treats it as whitespace
996
+ // Replace / with __SLASH__ in attribute context only (before = sign, after last >)
997
+ if (i < strings.length - 1) {
998
+ const lastEquals = str.lastIndexOf('=');
999
+ const lastCloseTag = str.lastIndexOf('>');
1000
+ if (lastEquals > lastCloseTag) {
1001
+ // We're in an attribute context - encode slashes in the attribute name
1002
+ const beforeEquals = str.substring(0, lastEquals);
1003
+ const attrStartIdx = beforeEquals.lastIndexOf('>') + 1;
1004
+ const attrPart = beforeEquals.substring(attrStartIdx);
1005
+ const encodedAttrPart = attrPart.replace(/\//g, '__SLASH__');
1006
+ str = beforeEquals.substring(0, attrStartIdx) + encodedAttrPart + str.substring(lastEquals);
1007
+ }
1008
+ }
994
1009
  htmlParts.push(str);
995
1010
  if (i < strings.length - 1) {
996
1011
  // Check if we're in an attribute context
@@ -998,13 +1013,15 @@ var Snice = (function (exports) {
998
1013
  const lastEquals = str.lastIndexOf('=');
999
1014
  const lastCloseTag = str.lastIndexOf('>');
1000
1015
  if (lastEquals > lastCloseTag) {
1001
- // We're in an attribute value - extract and preserve the original attribute name
1016
+ // We're in an attribute value - extract and preserve the original attribute name (before encoding)
1002
1017
  let attrStart = lastEquals - 1;
1003
1018
  while (attrStart >= 0 && /\S/.test(str[attrStart])) {
1004
1019
  attrStart--;
1005
1020
  }
1006
1021
  const attrName = str.substring(attrStart + 1, lastEquals).trim();
1007
- attrNamesForParts.push(attrName);
1022
+ // Decode the slash encoding to get original name
1023
+ const originalAttrName = attrName.replace(/__SLASH__/g, '/');
1024
+ attrNamesForParts.push(originalAttrName);
1008
1025
  htmlParts.push(marker);
1009
1026
  }
1010
1027
  else {