@webmate-studio/builder 0.2.173 → 0.2.175
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/package.json +1 -1
- package/src/html-cleaner.js +13 -6
package/package.json
CHANGED
package/src/html-cleaner.js
CHANGED
|
@@ -81,18 +81,25 @@ function transformIslandsToDataAttributes(html, availableIslands = [], component
|
|
|
81
81
|
return kebabTag;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
// Parse attributes string into
|
|
84
|
+
// Parse attributes string into a data-island-props JSON attribute.
|
|
85
|
+
// This preserves camelCase prop names (HTML attributes are case-insensitive
|
|
86
|
+
// and get lowercased by the browser, breaking camelCase like bgGray → bggray).
|
|
85
87
|
function parseAttrs(attrsString) {
|
|
86
|
-
const
|
|
87
|
-
const attrPattern = /([a-
|
|
88
|
+
const props = {};
|
|
89
|
+
const attrPattern = /([a-zA-Z][a-zA-Z0-9]*)\s*=\s*(?:\{([^}]+)\}|"([^"]*)"|'([^']*)')/g;
|
|
88
90
|
let attrMatch;
|
|
89
91
|
while ((attrMatch = attrPattern.exec(attrsString)) !== null) {
|
|
90
92
|
const propName = attrMatch[1];
|
|
91
93
|
const propValue = attrMatch[2] || attrMatch[3] || attrMatch[4];
|
|
92
|
-
|
|
93
|
-
|
|
94
|
+
// For {expression} values, use __WM_EXPR:name__ marker instead of {name}
|
|
95
|
+
// to prevent the template processor from evaluating them.
|
|
96
|
+
// ComponentLoader resolves these markers at runtime.
|
|
97
|
+
props[propName] = attrMatch[2] ? `__WM_EXPR:${propValue}__` : propValue;
|
|
94
98
|
}
|
|
95
|
-
|
|
99
|
+
if (Object.keys(props).length === 0) return '';
|
|
100
|
+
// Encode as JSON in data-island-props (preserves camelCase)
|
|
101
|
+
const json = JSON.stringify(props).replace(/"/g, '"');
|
|
102
|
+
return ` data-island-props="${json}"`;
|
|
96
103
|
}
|
|
97
104
|
|
|
98
105
|
// 1. Self-closing: <ComponentName attrs... />
|